I'm grouping profile
controller and I want to link to that. Then I define this route:
//Group to put all the routes that need login first
Route::group(array('prefix'=> 'admin', 'before' => 'csrf'), function(){
Route::resource('/profile' , 'ProfileController', array('as'=>'profile') );
});
and this is my menu link:
<li><a href="{{ URL::route('admin.profile') }}">profile Managment</a></li>
and this it my result of route
in terminal:
+--------+----------------------------------+------------------------+---------------------------+----------------+---------------+
| Domain | URI | Name | Action | Before Filters | After Filters |
+--------+----------------------------------+------------------------+---------------------------+----------------+---------------+
| | GET / | index | Closure | | |
| | GET admin/index | dashboard | Closure | | |
| | GET logout | logout | Closure | | |
| | POST auth | auth | Closure | csrf | |
| | GET login | login | Closure | | |
| | GET admin/profile | admin..profile.index | ProfileController@index | csrf | |
| | GET admin/profile/create | admin..profile.create | ProfileController@create | csrf | |
| | POST admin/profile | admin..profile.store | ProfileController@store | csrf | |
| | GET admin/profile/{profile} | admin..profile.show | ProfileController@show | csrf | |
| | GET admin/profile/{profile}/edit | admin..profile.edit | ProfileController@edit | csrf | |
| | PUT admin/profile/{profile} | admin..profile.update | ProfileController@update | csrf | |
| | PATCH admin/profile/{profile} | | ProfileController@update | csrf | |
| | DELETE admin/profile/{profile} | admin..profile.destroy | ProfileController@destroy | csrf | |
+--------+----------------------------------+------------------------+---------------------------+----------------+---------------+
Now I get this error:
ErrorException
Route [admin.profile] not defined. (View: /var/www/alachiq/app/views/back_end/menu.blade.php) (View: /var/www/alachiq/app/views/back_end/menu.blade.php) (View: /var/www/alachiq/app/views/back_end/menu.blade.php)
Remove the /
character from your Route::resource
method. It is causing the double dots, which in turn are causing your error message.
Should be:
Route::resource('profile' , 'ProfileController', array('as'=>'profile') );
Either format (/profile
or profile
) would usually work, but when using the prefix
option with Route::group
you need to remove the /
from resource URL.
EDIT: Also it seems to me that you should be pointing your link to route admin.profile.index
, not admin.profile
.
Why don't you just do URL::to('admin/profile');
Since what you're trying to achieve with URL::route('admin.profile');
is almost the same number of types away.
Now from what I understand, URL::route('profile');
will produce a full URL string to a a route with the same name you assigned to.
EDIT
echo URL::route('admin.profile.index');
Should work. Based from Docs, you should include .index under ROUTE NAME
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With