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

add softDelete to media model #49

Closed
pamo85 opened this issue Aug 21, 2015 · 4 comments
Closed

add softDelete to media model #49

pamo85 opened this issue Aug 21, 2015 · 4 comments

Comments

@pamo85
Copy link

pamo85 commented Aug 21, 2015

I use soft delete for my models.
Now, when I delete items, they get soft deleted but media gets hard deleted.
So any chance to get a soft delete option in a future version?

@freekmurze
Copy link
Member

Because I don't need this myself, it's not high on my priority list. If you need this feel free to submit a PR.

@nicolasbeauvais
Copy link
Contributor

For future readers you can simply override the delete method in the model using soft delete:

public function delete()
{
    return parent::delete();
}

The laravel-medialibrary delete method will not be called and will leave all medias untouched.

@freekmurze
Copy link
Member

Thanks for posting your solution!

@vesper8
Copy link

vesper8 commented May 28, 2017

@nicolasbeauvais

did the behaviour change? I just tried your solution and it did not prevent my media db rows from being deleted even though I added the code you posted to my App\User model.

After softDeleting the user both the images as well as the db row were removed

Do you have another workaround that works with latest version by any chance?

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

4 participants