PabloT
1 month ago
393
11
Laravel

Laravel routes - best practices.

Posted 1 month ago by PabloT

Hi,

Please, I need some advice. I'm building up an app that the client requires the URLs to be as the following example:

//www.radar.com
//-URL when you are on: Commercial site.

//www.radar.com/app/
//-URL when you are on: The app (service).

//www.radar.com/app/businesses/
//-URL when you are on: List of registered business on user's account.

//www.radar.com/app/businesses/visit-london-ltd/
//-URL when you are on: A selected business

//www.radar.com/app/businesses/visit-london-ltd/offices/
//-URL when you are on: List of offices a business has.

//www.radar.com/app/businesses/visit-london-ltd/offices/south-path-office/
//-URL when you are on: A selected office.

//www.radar.com/app/businesses/visit-london-ltd/offices/south-path-office/staff-members
//-URL when you are on: List of staff members an office has.

//www.radar.com/app/businesses/visit-london-ltd/offices/south-path-office/staff-members/[email protected]
//-URL when you are on: A selected staff member.

I have the application working but the URL's are not as the client wants... So far I have this set.

//App
Route::group(['prefix' => 'app' ], function () {
    //Business
    Route::resource('businesses', 'App\BusinessController');
    Route::group(['prefix' => 'businesses' ], function () {
        Route::resource('offices', 'App\OfficeController');
        Route::resource('members', 'App\MemberController');
    });
});
    

I would like to have the application following best practices/conventions, any advice? Thank you.

Please sign in or create an account to participate in this conversation.