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)
{
....
}
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?
"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
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.