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

[9.x] Add a new function withSoftDeletes in routes #44420

Closed
wants to merge 6 commits into from
Closed

[9.x] Add a new function withSoftDeletes in routes #44420

wants to merge 6 commits into from

Conversation

michaelnabil230
Copy link
Contributor

@michaelnabil230 michaelnabil230 commented Oct 2, 2022

Laravel allows models to have soft delete to not remove from the row form database. to add the date the resource is deleted.
This contribution allows a developer to create a resource route that supports soft delete routes.

For ex:

Route::resource('users', UserController::class)->withSoftDeletes();

@michaelnabil230 michaelnabil230 changed the title Add a new function withSoftDelete in routes [9.x] Add a new function withSoftDelete in routes Oct 2, 2022
@Rizky92
Copy link

Rizky92 commented Oct 2, 2022

withTrashed() already did this.

@michaelnabil230 michaelnabil230 changed the title [9.x] Add a new function withSoftDelete in routes [9.x] Add a new function withSoftDeletes in routes Oct 2, 2022
@michaelnabil230
Copy link
Contributor Author

withTrashed() already did this.

But don't generate routes for trashed or restore methods in your controller

@michaelnabil230 michaelnabil230 closed this by deleting the head repository Oct 2, 2022
@@ -92,6 +101,10 @@ public function register($name, $controller, array $options = [])

$defaults = $this->resourceDefaults;

if (isset($options['withSoftDeletes']) && $options['withSoftDeletes'] == true) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use strict equivalency

src/Illuminate/Routing/ResourceRegistrar.php Show resolved Hide resolved
src/Illuminate/Routing/ResourceRegistrar.php Show resolved Hide resolved
src/Illuminate/Routing/Router.php Show resolved Hide resolved
@browner12
Copy link
Contributor

@Rizky92 withTrashed() is similar but different that what is proposed here. withTrashed() will load soft deleted models when "route model binding" is happening.

Similar relevant PR I created a couple days ago #44405

@michaelnabil230
Copy link
Contributor Author

A new PR has been created that supports the new feature #44421

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.

3 participants