Laravel link to route not defined

laravel, laravel-4, php

Solution

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`.

Problem

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) ```

Original source