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

[8.x] Support withTrashed on routes #38348

Merged
merged 1 commit into from
Aug 12, 2021
Merged

[8.x] Support withTrashed on routes #38348

merged 1 commit into from
Aug 12, 2021

Conversation

taylorotwell
Copy link
Member

This allows you to specify a single route allows soft deleted models when resolving implicit model bindings:

Route::post('/user/{user}', function (ImplicitBindingModel $user) {
    return $user;
})->middleware(['web'])->withTrashed();

@ArielMejiaDev
Copy link

Thanks, @taylorotwell it improves the developer experience... brilliant!!!

@GrahamCampbell GrahamCampbell changed the title support withTrashed on routes [8.x] Support withTrashed on routes Aug 11, 2021
@taylorotwell taylorotwell merged commit 747f166 into 8.x Aug 12, 2021
@taylorotwell taylorotwell deleted the with-trashed-routes branch August 12, 2021 12:54
@forsvunnet
Copy link

forsvunnet commented Aug 17, 2021

Does this work with resource routes too?

@jrd-lewis
Copy link
Contributor

Does this work with resource routes too?

Just tried in a Laravel app I'm working on, and it looks like the withTrashed doesn't work with resource routes.

@goodevilgenius
Copy link
Contributor

I feel like an onlyTrashed route binding would be even more useful. That would be particularly useful for a "trashed" route.

@dennisprudlo
Copy link
Contributor

You can still abort_unless($model->trashed(), 404); if you want to only handle trashed models.

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

Successfully merging this pull request may close these issues.

None yet

6 participants