Support the ongoing development of Laravel.io →
Configuration
Last updated 2 years ago.
0

I would probably specify them all - although if you have a ton of routes in a dashboard you might want to think about splitting them out into different controllers

That said, you can use parameters in your routes:

Route::get('url/dashboard/{section}/{action}/{id}', 'DashboardController@dashboardMethod')->name('dashboard-method');

Controller:

public function dashboardMethod($section, $action, $id)
{
    ....
}
0

But what if I go to 'url/section' without any other parameters? Do I need to make a route without other attributes, or just set default value to null to attributes that are not used?

Splitting to different controllers... Like if I need Posts data for overview table instead of making method in Dashboard make getPostsOverviewForDashboard in PostController?

0

"But what if I go to 'url/section' without any other parameters? Do I need to make a route without other attributes, or just set default value to null to attributes that are not used?"

Route::get('url/dashboard/{section?}/{action?}/{id?}', 'DashboardController@dashboardMethod')->name('dashboard-method');

public function dashboardMethod($section = null, $action = null, $id = null)
{
    if($section)
    {
        ...
    }
    
}

"Splitting to different controllers... Like if I need Posts data for overview table instead of making method in Dashboard make getPostsOverviewForDashboard in PostController?"

It really depends on your app you might have:

dashboard/posts.php
dashboard/comments.php
....

Really depends on how you want to organise it

0

Thanks that's exactly what I was looking for! :)

0

Sign in to participate in this thread!

Eventy

Your banner here too?

lumitron lumitron Joined 10 Oct 2016

Moderators

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

Your logo here?

Laravel.io

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

© 2024 Laravel.io - All rights reserved.