Source: juststeveking.uk

Working with Laravel Model Events
When working with Eloquent Models, it is common to tap into the events dispatched through the Models lifecycle. This example will assign the model’s UUID property to a UUID during the creation of the model itself.

Model Observers are a class-based approach to reacting to model events, where the methods correspond to the specific events being fired.

This is a property on every Eloquent Model that allows you to list the events you want to listen for and a class called for these events.

The SetModelUuid will be instantiated during the lifecycle of the Eloquent model and is your chance to add behavior and properties to the model.
Newsletter

Get the latest Laravel/PHP jobs, events and curated articles straight to your inbox, once a week

Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge. Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge.
Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Shirts painstakingly handcrafted by under-caffeinated developers. Shirts painstakingly handcrafted by under-caffeinated developers.
Community Partners