What and Why
Laravel supports restful-nested-resources, which are configured by chaining them with dots.
Their behaviour is already partially supported with all those great relation-routes, but they only support one level of nesting/relation.
As I need another nesting level I tried using laravels dot notation, which did work partially, which is even worse than failing all together, as the results look correct, but are simply wrong.
Adding Routes works fine
I am adding new routes like:
Orion::belongsToManyResource('as.bs','cs', \App\Http\Controllers\Api\BCController::class);
which creates the expected routes like:
Method |
URI |
Name |
Action |
GET/HEAD |
api/as/{a}/bs/{b}/cs |
as.bs.cs.index |
App\Http\Controllers\Api\BCController@index |
POST |
api/as/{a}/bs/{b}/cs |
as.bs.cs.store |
App\Http\Controllers\Api\BCController@store |
... |
... |
... |
.... |
GET/HEAD |
api/as/{a}/bs/{b}/cs/{c?} |
as.bs.cs.show |
App\Http\Controllers\Api\BCController@show |
PUT/PATCH |
api/as/{a}/bs/{b}/cs/{c?} |
as.bs.cs.update |
App\Http\Controllers\Api\BCController@update |
... |
... |
... |
... |
(I am not sure why the c is marked optional, but thats not the point)
Controller doesn't work as expected
GET api/as/1/bs/2/cs
Expected Result
Listing of all Cs of B2 (given B2 is related to A1)
Real Result
Listing of all Cs of B1 (even if B1 is not related to any A)
GET api/as/1/bs/2/cs/3
Expected Result
C3 (given C3 is related to B2 and B2 is related to A1)
Current Result
C2 (with C2 being related to B1)
Further expectations
I'd expect the APolicy to be checked too, but it doesn't seem to be.
Cheers
I am a bit sad for the controller not working out of the box and me having to try getting it to work as expected or writing it myselfe by hand again -- but thats just because of how awesome orion is and how much time it did save me at all the other controllers, which did work just out of the box. Great work - so much appreciated!