Events

You're browsing the documentation for an old version of MoonShine. Consider upgrading your project to MoonShine 2.x.

Since MoonShine is based on standard eloquent methods for adding, editing and deleting, you can easily use standard Laravel events:

https://laravel.com/docs/9.x/eloquent#events

But sometimes you need to snap exactly to the events within the MoonShine resources! To do this, you need to implement the events you want in the resource

protected function beforeCreating(Model $item)
{
// Event before adding an entry
}
 
protected function afterCreated(Model $item)
{
// Event after adding a record
}
 
protected function beforeUpdating(Model $item)
{
// Event before record update
}
 
protected function afterUpdated(Model $item)
{
// Event after record update
}
 
protected function beforeDeleting(Model $item)
{
// Event before record deletion
}
 
protected function afterDeleted(Model $item)
{
// Event after record deletion
}
 
protected function beforeMassDeleting(array $ids)
{
// Event before mass deletion of records
}
 
protected function afterMassDeleted(array $ids)
{
// Event after mass deletion of records
}