code16/sharp
Code-driven CMS framework for Laravel (PHP 8.3+/Laravel 11+). Build admin/CMS sections with a clean UI and strong DX: CRUD with validation, search/sort/filter, bulk or custom commands, and authorization—no front-end code required, data-agnostic.
This feature makes it possible to add a message (with an alert or not) at the top of an Entity List, a Form (including a Command Form), a Show Page, a Dashboard or an Embed.

A global page alert can be great to provide feedback to the user, to remind him of a particular state, to warn him of potential consequences of a Command...
Create a buildPageAlert() method:
class MyShow extends SharpShow
{
// ...
protected function buildPageAlert(PageAlert $pageAlert): void
{
$pageAlert
->setLevelInfo()
->setMessage('This post is planned for publication');
}
}
You can use several styles: setLevelInfo(), setLevelWarning(), setLevelDanger(), setLevelPrimary() or setLevelSecondary().
To provide a dynamic message, depending on the actual data of the Show, Entity List and so on, you can pass a closure to the setMessage() method:
class MyShow extends SharpShow
{
// ...
protected function buildPageAlert(PageAlert $pageAlert): void
{
$pageAlert
->setLevelInfo()
->setMessage(function (array $data) {
return $data['is_planned']
? 'This post is planned for publication, on ' . $data['published_at']
: null;
});
}
}
The $data array passed to the closure is the result of your find() (Show, Form), getListData() (Entity List), buildWidgetsData() (Dashboard) or initialData() (Command) method.
::: tip
If your message is complex to build, you can defer to a blade template to encapsulate the logic, eg:
return view('sharp._post-planned-info', ['data' => $data])->render();
:::
The setButton() method allows you to add a link to your alert:
class MyShow extends SharpShow
{
// ...
protected function buildPageAlert(PageAlert $pageAlert): void
{
$pageAlert
->setMessage('This page has been edited recently.')
->setButton('Go to page', route('pages.show', sharp()->context()->instanceId()));
}
}
You can also pass a SharpLinkTo object. It's useful for filtering an Entity List, for example:
class MyEntityList extends SharpEntityList
{
// ...
protected function buildPageAlert(PageAlert $pageAlert): void
{
$pageAlert
->setMessage('There are new orders to handle.')
->setButton('See orders', LinkToEntityList::make(MyEntity::class)
->addFilter('is_new', 1)
);
}
}
The onSection() method allows you to specify the section where the alert should be displayed (instead of the default, the top of the page):
class MyShow extends SharpShow
{
// ...
protected function buildShowLayout(ShowLayout $showLayout): void
{
$showLayout
->addSection(function (ShowLayoutSection $section) {
$section
->setKey('content')
->addColumn(/* ... */);
})
->addSection(/* ... */);
}
protected function buildPageAlert(PageAlert $pageAlert): void
{
$pageAlert
->setMessage('This page has been edited recently.')
->onSection('content');
}
}
How can I help you explore Laravel packages today?