Skip to content

Commit

Permalink
document withTrashed on routes
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Aug 17, 2021
1 parent fed704c commit a6b8354
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions routing.md
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,17 @@ Of course, implicit binding is also possible when using controller methods. Agai
return view('user.profile', ['user' => $user]);
}

<a name="implicit-soft-deleted-models"></a>
#### Soft Deleted Models

Typically, implicit model binding will not retrieve models that have been [soft deleted](/docs/{{version}}/eloquent#soft-deleting). However, you may instruct the implicit binding to retrieve these models by chaining the `withTrashed` method onto your route's definition:

use App\Models\User;

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

<a name="customizing-the-key"></a>
<a name="customizing-the-default-key-name"></a>
#### Customizing The Key
Expand Down

0 comments on commit a6b8354

Please sign in to comment.