This is something I don't understand quite well I making making an App for my self using Laravel and would like to upkeep to standards.
So I have the following:
class UserController extends BaseController {
GET index(), show(), new(), edit()
POST create()
PUT update()
DELETE destroy()
}
class UserModel { hasMany->Assets }
class Asset { pulic function fetchAssetsFromApi(); }
Now I don't have an Asset controller because there is nothing about Asset that needs to be displayed on it's own. I simply have the model for the ORM purposes to represent assets
table.
Now the Assets model has a method that pulls Assets associated with a particular User and adds them to the database.
Now my view that is rendered by UserController->show
has a button called Update Assets that should call fechAssetsFromApi()
to update characters assets. However since there is no way to invoke alone with a button I would have to POST to a controller.
Meaning now I would need to have another method in my UsersController
since it's the only one that will be using Assets model.
Now my question is does this break rules and guidelines for RESTfull controllers ? I will have this similar dilema appear multiple time in application ho should i approach it.
Should a proper RESTFull controller contain only CRUD or ?