You need to name your route, like so :
Route::get('dashboard', array('as' => 'dashboard', 'uses' => 'PagesController@showDashboard'));
You can also use the action
helper when building the link like so:
<a href="{{ action("PagesController@showDashboard") }}">link</a>
It will generate a URL based on the routes table.
Thank you both very much! That's very helpful.
Please note
<a href="{{ action("PagesController@showDashboard") }}">link</a>
does not work if the controller manages a number of different views
However, you can check the actual routes (rather than url)'s using:
php artisan route:list
I prefer to use route() wherevere possible, don't know if it is a common aproach though:
Route::get('dashboard', ['as' => 'dashboard', 'uses' => 'PagesController@showDashboard']);
...
<a href="{{ route('dashboard') }}">Dashboard</a>
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community