ycliper

Популярное

Музыка Кино и Анимация Автомобили Животные Спорт Путешествия Игры Юмор

Интересные видео

2025 Сериалы Трейлеры Новости Как сделать Видеоуроки Diy своими руками

Топ запросов

смотреть а4 schoolboy runaway турецкий сериал смотреть мультфильмы эдисон
Скачать

Part 9: Eloquent Events - Laravel 5.4 New Features

Автор: DevMarketer

Загружено: 2017-02-20

Просмотров: 19139

Описание: In Laravel 5.4 we can now tie eloquent events to our normal event classes. This allows us to tuck custom functionality to when new models and items are added to our database with very little effort.

While it might seem confusing at first for a newcomer, the events system requires several files but it makes sense once you wrap your head around it.

The file that controls all events is the EventServiceProvider. This is the file that displays all the events to listen for and the listeners to fire when the event is triggered. You can set up these relationships in a basic associated array format, with as many listeners as you want tied to a specific event.

Once you set up the relationship you can generate the files needed, by using the artisan console command:

php artisan event:generate

This will create an Events and a Listeners folder with the new events and listeners files inside them.

We will customize the event file only because we want to tell the event to pass a user eloquent object along to the listener, otherwise there would be no other need to customize this file. By customizing this file, we tell it to pass the user object to the listener.

In the listener, we can tell the listener which code to execute by putting the code in the Handler() function. For this tutorial, this is where we add the Mail command.

This is the basic event/listener relationship, but when we want to tie it to your Eloquent events, then we establish the connection in our model. In our case, it is the User model. In the user model, we will create a new protected attribute called $events and then set up the eloquent event to our custom Event Classes as shown in the video.

Now when the eloquent event fires, it triggers our custom Event class and then fires the listener.

For more information about Events/Listeners in general:
https://laravel.com/docs/5.4/events

For more information about Eloquent Events:
https://laravel.com/docs/5.4/eloquent...

Не удается загрузить Youtube-плеер. Проверьте блокировку Youtube в вашей сети.
Повторяем попытку...
Part 9: Eloquent Events - Laravel 5.4 New Features

Поделиться в:

Доступные форматы для скачивания:

Скачать видео

  • Информация по загрузке:

Скачать аудио

Похожие видео

Part 8: Markdown Email Mailables - Laravel 5.4 New Features

Part 8: Markdown Email Mailables - Laravel 5.4 New Features

Laravel 5.4 New Features - Part 1: All the Small Changes Overview

Laravel 5.4 New Features - Part 1: All the Small Changes Overview

Part 5: Generate Models - Laravel 5.4 New Features

Part 5: Generate Models - Laravel 5.4 New Features

Websockets in Laravel: Part 0 - What are Websockets?

Websockets in Laravel: Part 0 - What are Websockets?

Part 7: Laravel Dusk - Laravel 5.4 New Features

Part 7: Laravel Dusk - Laravel 5.4 New Features

«Будем жить!» | Хитрая передача на Первом канале о вернувшихся с СВО (English subtitles) @Max_Katz

«Будем жить!» | Хитрая передача на Первом канале о вернувшихся с СВО (English subtitles) @Max_Katz

Похудей на 45 КГ, Выиграй $250,000!

Похудей на 45 КГ, Выиграй $250,000!

100 ДНЕЙ ВЫЖИВАНИЯ В СТРАШНОМ РЕАЛИСТИЧНОМ МАЙНКРАФТЕ

100 ДНЕЙ ВЫЖИВАНИЯ В СТРАШНОМ РЕАЛИСТИЧНОМ МАЙНКРАФТЕ

Кризис в российских регионах: проблемы даже у богатых нефтью

Кризис в российских регионах: проблемы даже у богатых нефтью

Laravel 6 Advanced - e1 - Service Container

Laravel 6 Advanced - e1 - Service Container

© 2025 ycliper. Все права защищены.



  • Контакты
  • О нас
  • Политика конфиденциальности



Контакты для правообладателей: [email protected]