Skip to main content
Quick Tip

assign withTrashed() to Route::resource() method

Before Laravel 9.35 - only for Route::get()

Route::get('/users/{user}', function (User $user) {
return $user->email;
})->withTrashed();

Since Laravel 9.35 - also for Route::resource()!

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

Or, even by method

Route::resource('users', UserController::class)
->withTrashed(['show']);

Enjoyed This Tip?

Get access to all premium tutorials, video and text courses, and exclusive Laravel resources. Join our community of 10,000+ developers.

We'd Love Your Feedback

Tell us what you like or what we can improve

Feel free to share anything you like or dislike about this page or the platform in general.