Suppose we have a M:M relationship between a User
model and a Project
model in a project management SaaS. Naturally we have a pivot table mapping users to projects. An entry is deleted either if the user leaves or if the project manager removes that user from the project.
Even though the final result is essentially the same (i.e., the entry is deleted), I imagine it would be better to distinguish between these two actions by defining two separate API endpoints as follows:
user leaves project
route DELETE /users/{id}/projects/{id}
action UserProjectController@destroy($id)
where $id
refers to the project
project manager removes user
route DELETE /projects/{id}/participants/{id}
action ProjectParticipantController@destroy($id)
where $id
refers to the user
Should I ignore Cruddy by Design and RESTful design principles and simply define leave()
join()
remove()
actions instead and use verbs in the URIs? like so:
POST /projects/{id}/join
POST /projects/{id}/leave
POST /projects/{id}/participants/{id}/remove