DolDurma
DolDurma

Reputation: 17303

Laravel link to Controller

i have this menu item such as :

<li><a href="{{ URL::route('profile') }}"> Profile Managment </a></li>

and i want to route that to ProfileController. this below my route do not work.

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

i want to route that if user can login and can see profile page and that nust be send all Request to ProfileController.

Error Result:

Error in exception handler: Route [profile] not defined. (View: /var/www/laravel/app/views/back_end/menu.blade.php) (View: /var/www/laravel/app/views/back_end/menu.blade.php) (View: /var/www/laravel/app/views/back_end/menu.blade.php) in /var/www/laravel/vendor/laravel/framework/src/Illuminate/Routing/UrlGenerator.php:207

Upvotes: 2

Views: 14434

Answers (2)

The Alpha
The Alpha

Reputation: 146191

Actualy Laravel will create following routes

Route(URL)                                      | Name
------------------------------------------------------------------
GET profile                                     | profile.index
GET profile/create                              | profile.create
POST profile                                    | profile.store
GET profile/{profile}                           | profile.show
GET profile/{profile}/edit                      | profile.edit
PUT profile/{profile}                           | profile.update
PATCH profile/{profile}                         |
DELETE profile/{profile}                        | profile.destroy

For this

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

If you run php artisan routes from your terminal/command prompt then you'll get all the route's list with name and url.

Upvotes: 3

Antonio Carlos Ribeiro
Antonio Carlos Ribeiro

Reputation: 87719

Probably you'll have to:

<li><a href="{{ URL::route('profile.index') }}"> Profile Managment </a></li>

To be sure, execute

php artisan routes

Laravel will show the list of routes and names you have to use.

Also, you have access to more info in the docs: http://laravel.com/docs/controllers#resource-controllers

Upvotes: 1

Related Questions