At a first glance, it's simple: another CRUD-like resource for Parking, and we're done? But here's where you have a lot of room to choose from, how to structure the API endpoints and Controller methods.
- Should it be
/parkings/startand/parkings/stop? - Should it be
POST /parkingsandPUT /parkings? - Some other structure?
I posted this question on Twitter - you can read the replies or watch my re-cap on YouTube: To CRUD or Not To CRUD?.
In short, there are at least a few ways to structure this. I would go for a non-standard-CRUD approach and create a ParkingController with start/stop methods.
Hi Povilas, question regarding your code under start method of ParkingController:
Is it still necessary to use the load function to eager load vehicle and zone? i believe there wont be any N+1 problem knowing that there will only be one vehicle and one zone per parking.
Right, you're probably right, this time I was overly cautious. But better safe than sorry! :)
This is the first time seeing this syntax. I'm happy to always learn something new in Laravel. It gives the confidence that I am getting far deeper into the framework everyday. Thanks a lot.
Since there will be only one record, is that the reason that show() and stop() method does not load relationships before passing to resource class like in the start() method ? thanks