Support the ongoing development of →
posted 9 years ago
Last updated 2 years ago.

I think both ways will work, but I am thinking of controllers as classes that manage particular resource. Also laravel has some Route methods that make your life easier if you go this way.


Route::resource('lead', 'LeadController');
Route::resource('inquiry', 'InquiryController');

In LeadController you can have a "index" method that will show all cars/leads available and a "show" method that will display a single car info page
In InquiryController you can have a "store" method that will store new inquiry for a car

Last updated 9 years ago.

Thanks TorchSK. I like the cleanness of this solution, but I wonder about the usage of LeadController for the car info page display. I think it works within this relatively straightforward scenario, but what if the page also contained info about an associated dealership. Which resource would be the 'primary' resource who's controller would get used? In that type of situation, would it be better to name the controller for the page name, and have it manage both resources ('leads' and 'dealers')?


Well it is a Lead information page. So the view should be called from Lead controller. This Lead controller can of course display another info than lead info (e.g. dealer info).

I would leave the name of this controller as LeadController, and in the show method just fetch all the data you need for thew view(page).


Sign in to participate in this thread!


Your banner here too?

jegra jegra Joined 19 Jan 2015


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.