79512979

Date: 2025-03-16 17:53:25
Score: 1.5
Natty:
Report link

Found a nice and easy answer. For laravel 11.x you can just add to the User model and will do the trick

protected static function boot() {
    parent::boot();

    static::deleting(function($user) {
        $user->projects()->update(['user_id' => null]);
    });
}
Reasons:
  • Low length (0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: TomasEzequiel