cristianhu06 / datatables--jest

0 stars 0 forks source link

7. Observers #7

Open cristianhu06 opened 1 year ago

cristianhu06 commented 1 year ago

ejecutar el suguiente comando 💯

php artisan make:observer ArticuloObserver

cristianhu06 commented 1 year ago
class ArticuloObserver
{
    public function creating(Articulos $articulos){
        $articulos->sort = Articulos::max('sort') + 1;
    }
}
cristianhu06 commented 1 year ago

C:\laragon\www\datatablesv9x\app\Providers\EventServiceProvider.

actualizamos nuestro evento.

public function boot()
    {
        Articulos::observe(\App\Observers\ArticuloObserver::class);
    }