Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Jan 22, 2019
1 parent 7a442bc commit d83c78a
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion routing.md
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,11 @@ If a matching model instance is not found in the database, a 404 HTTP response w

If you wish to use your own resolution logic, you may use the `Route::bind` method. The `Closure` you pass to the `bind` method will receive the value of the URI segment and should return the instance of the class that should be injected into the route:

/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
parent::boot();
Expand All @@ -361,8 +366,14 @@ If you wish to use your own resolution logic, you may use the `Route::bind` meth
});
}

You may also override the `resolveRouteBinding` method on the Eloquent model:
Alternatively, you may override the `resolveRouteBinding` method on your Eloquent model. This method will receive the value of the URI segment and should return the instance of the class that should be injected into the route:

/**
* Retrieve the model for a bound value.
*
* @param mixed $value
* @return \Illuminate\Database\Eloquent\Model|null
*/
public function resolveRouteBinding($value)
{
return $this->where('name', $value)->first() ?? abort(404);
Expand Down

0 comments on commit d83c78a

Please sign in to comment.