Laravel Model boot() Method

In laravel eloquent model have a magical method is called the boot() method. You can override the default behavior. Suppose you want to set up some field value at the moment of creating the model in laravel then you can declare the field’s value in the boot() method.

For example, you want to generate the UUID field then use the following example code.

Being Tricky 😉

Leave a Reply

Your email address will not be published. Required fields are marked *