I understand that a Resource controller can have the following methods
index
show
create
edit
store
update
destroy
Now suppose I have the following actions which need to be performed in addition to the resource actions:
- User attempts to log in.
- Admin wishes to find a user by email / first-name
- User requests a post by it's slug
Are resource controllers useless for the above functionality? If programming an API, I obviously want the index, show, edit,create,destroy... but also the login, find, search etc...
Is it possible to route to both types of controller? e.g.
Route::group(['prefix' => 'api'], function() {
Route::group(['prefix' => 'v1'], function() {
// Resource Controller
Route::resource('posts', 'ApiV1PostsResourceController');
// Restful Controller
Route::controller('posts', 'ApiV1PostsController');
});
});
Or should I just forget about the resource controller and use a restful controller instead?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…