Automatically deleting related rows in Laravel (Eloquent ORM)

后端 未结 13 1962
半阙折子戏
半阙折子戏 2020-11-22 17:03

When I delete a row using this syntax:

$user->delete();

Is there a way to attach a callback of sorts, so that it would e.g. do this auto

13条回答
  •  甜味超标
    2020-11-22 17:48

    As of Laravel 5.2, the documentation states that these kinds of event handlers should be registered in the AppServiceProvider:

    photos()->delete();
            });
        }
    

    I even suppose to move them to separate classes instead of closures for better application structure.

提交回复
热议问题