Skip to content

[9.x] only load trashed models on relevant routes#44478

Merged
taylorotwell merged 1 commit intolaravel:9.xfrom
browner12:trashed-resources
Oct 5, 2022
Merged

[9.x] only load trashed models on relevant routes#44478
taylorotwell merged 1 commit intolaravel:9.xfrom
browner12:trashed-resources

Conversation

@browner12
Copy link
Contributor

As I was writing the docs for #44405, I came to the realization it didn't make a lot of sense to load trashed models for some of the default resource routes. This PR will make it so calling ->withTrashed() with no arguments only loads trashed models on the show, edit, and update routes.

  • index, create, and store don't use route model binding, so from a performance and simplicity standpoint, we don't need to load those routes with trashed models
  • it doesn't make a lot of sense to load soft deleted models on the destroy route.

Curious to hear if there'd be any argument for continuing to load soft deleted models on the destroy route.

If this gets merged before next Tuesday's release we'll be okay keeping this on 9.x, since it's technically a breaking change.

If this gets merged I'll need to make a minor adjustment to laravel/docs#8277

- `index`, `create`, and `store` don't use route model binding, so from a performance and simplicity standpoint, we don't need to load those routes with trashed models
- it doesn't make a lot of sense to load soft deleted models on the `destroy` route.
@taylorotwell taylorotwell merged commit 5cc435d into laravel:9.x Oct 5, 2022
@browner12 browner12 deleted the trashed-resources branch October 5, 2022 16:01
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.

2 participants

Comments