0

i have resource in route and that work correctly and i want to change that to Route::controller.

but after define that i get error in php artisan route :

   +--------+------------------------------------+-----------+---------------------------------+----------------+---------------+
    | Domain | URI                                | Name      | Action                          | Before Filters | After Filters |
    +--------+------------------------------------+-----------+---------------------------------+----------------+---------------+
    |        | GET index                          | index     | Closure                         |                |               |
    |        | GET admin/index                    | dashboard | Closure                         |                |               |
    |        | GET logout                         | logout    | Closure                         |                |               |
    |        | POST auth                          | auth      | Closure                         | csrf           |               |
    |        | GET login                          | login     | Closure                         |                |               |
    |        | GET admin/admin/profile/{_missing} |           | ProfileController@missingMethod |                |               |
    +--------+------------------------------------+-----------+---------------------------------+----------------+---------------+

my Current route is:

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

and i want to change that to :

Route::controller('admin/profile', 'ProfileController', array('index'=>'profile.index') );

how to resolve this problem?

2 Answers 2

2

This is not an error, Resource and Controller routes are completely different things.

Resource routes have a predefined list of routes (index, create, store, delete, update). If you don't have the method set in your controller it will still work, unless someone hit that route.

Controller routes relies on your controller methods:

public function getIndex() {}
public function getCreate() {}
public function postStore() {}

Methods names are predefined as

<http method><your action name>()

If those methods are not present in your controller, Laravel will not show them in your routes list.

So, just create a

public function getIndex() {}

In your controller and run

php artisan route

Again.

Sign up to request clarification or add additional context in comments.

3 Comments

thanks. i get this result now.GET admin/admin/profile/index/{one?}/{two?}/{three?}/{four?}/{five?} how to set as for that? my link is /admin/profile how to resolve this problem?
Are those routes inside a route::group?
i have one route into group
0

Use :

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

Instead of either the routes above.

2 Comments

I did read your question, and I agreed with they guy who gave an answer in this post. Using ::controller is a bad practice and should be avoided. For that reason, I recommended the above line of code that should accomplish your requirements.
and your offer is resource :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.