php - Laravel route to controller not working -
i'm trying add new controller existing laravel project. application has pages @ /users , trying add restful api works separately this. api available @ api/users.
i have created controller using php artisan:
php artisan controller:make apiuserscontroller i have added following routes:
route::controller('api/users', 'apiuserscontroller'); however when hit url receive site's 'page not found' message.
is there have missed?
it looks issue you're having you've used route::controller rather route::resource.
route::resource maps routes 7 restful methods controller generator creates default. route::controller maps them methods add have http method part of name, in case if had method called getindex called on request /api/users/index or if had 1 called poststore called on post request /api/users/store.
in order add api prefix route use following:
route::group(['prefix' => 'api'], function() { route::resource('users', 'controllername'); }); you add other controllers in api within same callback.
Comments
Post a Comment