Level 4
If you have static pages you may store titles depend on route names in config folder and use it. last time i found this simple solution for my admin panel.
code example
config.php
return [
'tasks.index' => 'All Tasks',
'tasks.create' => 'New Task',
'tasks.edit' => 'Edit Task',
'tasks.show' => 'Task Details',
];
helpers.php
function getTitle() {
$titles = config('titles');
$currentRouteName = Route::currentRouteName();
if( isset( $titles[$currentRouteName] ) ) {
return $titles[$currentRouteName];
}
return '';
}
in layout file
<h1>{{ getTitle() }}</h1>
2 likes