Skip to content

Commit

Permalink
URL generation.
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Feb 24, 2015
1 parent 9a8889a commit a8ab80b
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions eloquent.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
- [Attribute Casting](#attribute-casting)
- [Model Events](#model-events)
- [Model Observers](#model-observers)
- [Model URL Generation](#model-url-generation)
- [Converting To Arrays / JSON](#converting-to-arrays-or-json)

<a name="introduction"></a>
Expand Down Expand Up @@ -1292,6 +1293,22 @@ You may register an observer instance using the `observe` method:

User::observe(new UserObserver);

<a name="model-url-generation"></a>
## Model URL Generation

When you pass a model to the `route` or `action` methods, it's primary key is inserted into the generated URI. For example:

Route::get('user/{user}', 'UserController@show');

action('UserController@show', [$user]);

In this example the `$user->id` property will be inserted into the `{user}` place-holder of the generated URL. However, if you would like to use another property instead of the ID, you may override the `getRouteKey` method on your model:

public function getRouteKey()
{
return $this->slug;
}

<a name="converting-to-arrays-or-json"></a>
## Converting To Arrays / JSON

Expand Down

0 comments on commit a8ab80b

Please sign in to comment.