Laravel link to route undefined

I am grouping a controller profileand I want to reference it. 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 is my result routein the 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)
+3
source share
2 answers

Remove the character /from your method Route::resource. This causes double dots, which in turn cause an error message.

Must be:

Route::resource('profile' , 'ProfileController', array('as'=>'profile') );

Any format ( /profileor profile) usually works, but when using the option prefixwith Route::groupyou need to remove the URL /from the URL of the resource.

EDIT: , admin.profile.index, admin.profile.

+4

URL::to('admin/profile');

URL::route('admin.profile');, .

, , , URL::route('profile'); URL- , .

echo URL::route('admin.profile.index');

. Docs, .index ROUTE NAME.

+2

All Articles