I have an application I've built using Laravel. I'm just trying to understand the right naming conventions for the application. Since Laravel is RESTful, I want to stick the right naming conventions for REST.
Suppose I have a User
resource who has a Car
resource. So I am saving the user_id
foreign key in my cars
table. In the application, I want to update the details of the car using PUT
. So how do I name my URI? Below are the three options that I'm considering. But I want to know which once is right:
1. /user/{id}/car/{id}
2. /car/{id}
3. /user/car/{id}
My question is, should I include the parent resource (user) in the URI or can I just use the car ID and update it? I have seen in some places (like the GitHub API) that they use the parent resource before the child resource.
If there is a duplicate question for this, please do let me know, as I searched for the exact answer before posting here, but couldn't find any.