Laravel 5.5 lesson - 11 Eloquent Events and Observers

preview_player
Показать описание
In this video I am explaining how eloquent events and observers works in laravel with a demo.

In the project code, i have commented the code for events and observers, if you would like to try this, please uncomment the code in respective files.

Commands used in this demo:

php artisan make:event CustomerCreated

Complete Project github link:

Laravel tutorials palylist:

If you like my videos please do subscribe to my channel.

Thanks.
Рекомендации по теме
Комментарии
Автор

These videos are very helpful for people starting out with laravel- and really shows the initial, built-in power. Thanks, Ruby!

fluidexpression
Автор

the newer versions of laravel have added the observer artisan command "php artisan make:observer UserObserver --model=User"

anili
Автор

Hello friend, the recommended thing to do is to add in the boot of the model, and not in the AppServiceProvider, therefore you are loading the observer every time your application is loaded.
When the correct one is to load the observer when the model is called.
Staying like this:

class Admin extends Authenticatable
{

public static function boot ()
     {
         parent :: boot ();
         Admin :: observe (new \ App \ Observers \ AdminObserver ());
     }
}

Sorry my bad english

jeffersonmoraes
Автор

why do we need to use observer ? just for an insert data, no need to use complicated code right?

astechsoftware
Автор

php artisan make:observer UserObserver

yaroslavsalata