Model events

Eloquent fires numerous events at different points, such as when a model is being saved or deleted. The following is a list of methods Eloquent models can fire:

  • creating
  • created
  • updating
  • updated
  • saving
  • saved
  • deleting
  • deleted
  • restoring
  • restored

The names are self-explanatory. The difference in the past and present participles is that events such as creating are fired before the model is created, whereas created is fired after the model has been created. Therefore, if you were to halt execution within a handler for the creating event, the record will not be saved; whereas, if you halted execution within a handler for the created event, the record would still be persisted to the database.

Registering event listeners

It's quite open-ended as to where ...

Get Laravel 5 Essentials now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.