inpin/lara-alert
inpin/lara-alert is a lightweight Laravel package for managing and displaying alert messages. It helps you flash success, error, warning, and info feedback and render consistent alerts in your Blade views with minimal setup, keeping notification handling simple and avoiding repetitive markup.
Install the package with Composer and run any required publish/migration steps:
composer require vendor/package
php artisan vendor:publish --tag=package-config
php artisan migrate
Add the Alertable trait to each model that should own alerts:
use Vendor\Package\Concerns\Alertable;
class Post extends Model
{
use Alertable;
}
Start with the new deletion workflow from release 1.0.2: create or retrieve an alert, then remove it through the trait method rather than deleting the record directly.
$post->deleteAlert($alert); // confirm exact signature in the trait
Look first at the Alertable trait source and the package README for the existing create/list methods. The new deleteAlert method is the main addition in 1.0.2.
Post, Order, or User, rather than centralizing all alert behavior on a single model.public function destroyAlert(Post $post, Alert $alert)
{
abort_unless($alert->alertable_id === $post->id, 403);
$post->deleteAlert($alert);
return back()->with('status', 'Alert deleted.');
}
DB::transaction(function () use ($post, $alert) {
$post->deleteAlert($alert);
// related cleanup
});
Alert::destroy() or query-builder deletes so package behavior, events, and future logic remain centralized.$post->deleteAlert($alert);
$this->assertDatabaseMissing('alerts', [
'id' => $alert->id,
]);
deleteAlert.deleteAlert signature in the trait before depending on it. It may accept an alert model, an ID, or another package-specific value.deleteAlert hard-deletes, soft-deletes, or dispatches events. If the alert model uses SoftDeletes, adjust assertions and UI expectations accordingly.deleteAlert for normal application flows.DB::listen callback to see the actual query and event flow.How can I help you explore Laravel packages today?