laravel / framework

The Laravel Framework.
https://laravel.com
MIT License
32.55k stars 11.03k forks source link

Soft-deletion of Model does not trigger `deleted` event in Observer #50422

Closed hendurhance closed 8 months ago

hendurhance commented 8 months ago

Laravel Version

10.0

PHP Version

8.2

Database Driver & Version

MySQL 8.0.32 for macOS 14.3.1 on Apple Silicon (Homebrew)

Description

When attempting to soft-delete a model that implements soft deletion (using Laravel's SoftDeletes trait), the deleted event defined in the model's observer does not fire as expected. This issue is encountered when using Laravel's built-in soft deletion functionality.

Steps To Reproduce

  1. Create a model with soft deletion enabled using Laravel's SoftDeletes trait.
  2. Implement an observer for the model and define event handling methods (deleted, restored, etc.).
  3. Soft-delete an instance of the model using the delete() method or a similar soft-deletion mechanism.
  4. Observe that the deleted event defined in the model's observer does not fire.
driesvints commented 8 months ago

This event isn't fired when deleted. Instead trashed is fired.

hendurhance commented 8 months ago

This event isn't fired when deleted. Instead trashed is fired.

The event trashed isn't fired either.