1. Go to this page and download the library: Download shooka/laravel-modelevents library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
shooka / laravel-modelevents example snippets
Shooka\ModelEvents\ServiceProvider::class,
App\Providers\ModelEventServiceProvider::class,
>Shooka\ModelEvents\ServiceProvider::class,
>
class Product extends Model
{
protected $observables = [
'sold',
'shipped',
'returned',
...
];
}
class ProductEvent extends ModelEvent
{
public function returned($product) {
// Increase stock count
}
}