tonning/flashable

A simple trait to flash when model events are fired, like `created`, `updated`, and `saved`.

1.1.1 2020-03-20 16:49 UTC

This package is auto-updated.

Last update: 2024-03-29 03:32:07 UTC


README

A simple trait to flash when model events are fired, like created, updated, and saved. Using Jeffrey Way's excellent Flash package to actually display the flash messages.

Installation

Begin by pulling in the package through Composer.

composer require tonning/flashable

Then add the trait to the model you want to automatically flash on crud actions.

use Tonning\Flashable\Flashable;

class Post extends Model
{
    use Flashable;
    
    ...
}

Customization

You can specify the name of the model by adding a getModelName method on you model.

public function getModelName() {
  return 'Blog post';
}

For even more fine grain control you can add a protected property on the model.

protected $flashable = [
  'created' => 'Your blog post have been created. Good job!',
  'updated' => 'I hope nobody saw those mistakes...',
  'deleted' => 'Be gone blog post!'
]