lewis4u lewis4u - 1 year ago 69
PHP Question

Laravel - Request::is() doesn't work as it should

I have 4 different titles



end customers


and i have only one view (one laravel.blade.php file) with this code

@if (Request::is('/admin/users'))
Alle Benutzer

and in my layout i have


and in my routes i have

Route::get('/admin/users', 'AdminController@showUsers');
Route::get('/admin/agencies', 'AdminController@showAgencies');
Route::get('/admin/endcustomers', 'AdminController@showEndCustomers');
Route::get('/admin/inactive', 'AdminController@showInactiveUsers');

And which ever site i call the title is always Inactive
What am i doing wrong....why the title doesn't change?

Answer Source

Well, you can't use the "Request" in the view.

I suggest you send the title from the controller like this:

return view('%the name of the view%', ['title'=>"%Your title%"]);

Then in the view, you can put this

<title> {{$title }} </title>
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download