Support the ongoing development of →
Requests Eloquent
Last updated 2 years ago.

I usually do something like this:

// routes.php
Route::model('client', 'Client');
Route::model('dealer', 'Dealer');
Route::model('branch', 'Branch');
Route::resource('client/{client}/dealer/{dealer}/branch', 'BranchController');

public function index(Client $client, Dealer $dealer){ .. }
public function show(Client $client, Dealer $dealer, Branch $branch){ .. }

I don't know if that it was you mean? Instead of model binding you can also just use the ID's, but I think this makes it a lot easier.

Last updated 2 years ago.

If I understand you correctly, what you're looking for are nested resources.
Here's a great tutorial by Jeffrey Way that will answer your question.

Laravel: Nested resources

But if you just want the answer:

Route::resource('', 'YourController');
Last updated 2 years ago.

@barryvdh Thanks for the other idea on how to resolve this case. I will also use this solution.

@zanmoskotevc Yup, I'm looking for that tutorial.. I forgot what the name of the video is, thanks for bringing it up.

Last updated 2 years ago.


If I want to use


instead of


how can I achieve this?


This directly matters only if U plan to use Route-Model Binding.

If you would like model binding to use a database column other than id when retrieving a given model class, you may override the getRouteKeyName method on the Eloquent model:

 * Get the route key for the model.
 * @return string
public function getRouteKeyName()
    return 'slug';

In case U aren't using route model binding, feel free to interpret the parameter as any field within the controller method, or the route handler closure.

Last updated 7 years ago.

Sign in to participate in this thread!


Your banner here too?

iamgerwin iamgerwin Joined 9 Dec 2013


We'd like to thank these amazing companies for supporting us

Your logo here?

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 - All rights reserved.