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

Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future. Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future.
Community Partners