Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update model props in "deleting" event observer #31754

Closed
alecpl opened this issue Mar 5, 2020 · 1 comment
Closed

Update model props in "deleting" event observer #31754

alecpl opened this issue Mar 5, 2020 · 1 comment

Comments

@alecpl
Copy link

alecpl commented Mar 5, 2020

  • Laravel Version: 5.8.37
  • PHP Version: 7.4.3
  • Database Driver & Version: sqlite

Description:

This might be not a bug, but a limitation and an expected behavior, but I didn't find it mentioned in docs.

namespace App\Observers;

use App\User;

class UserObserver
{
    public function deleting(User $user)
    {
        $user->status |= User::STATUS_DELETED;
    }
}

The model uses softDeletes, so it may look redundant while there's deleted_at property. However, I have a use case for this and I can imagine a case where I would want to change some other props on delete.

Should the UPDATE query (the one that sets deleted_at) after the event is fired include the status column? Would be nice. Note that I would not expect updating/updated event be invoked in this case.

Edit: Corrected method name in the code above from deleted to deleting.

@driesvints
Copy link
Member

Hey there,

Unfortunately we don't support this version anymore. Please check out our support policy on which versions we are currently supporting. Can you please try to upgrade to the latest version and see if your problem persists? We'll help you out and re-open this issue if so.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants