Hi, I have DB entities User and Item and they have relation many-to-many (user has access to many items and one item is accesible by many users). There are attributes in the pivot table item_user:
I have Laravel models User and Item which have many-to-many relationship via item_user. I do NOT have Access model for the pivot table (I want composite key only and Laravel does not support composite keys). I want to create symmetric REST API (no "Access" resource):
The question is, which of PUT, POST to use when I want to link user with item? If I use
then Laravel generates this:
Obviously, the first route does not make sense (I want to link existing user with existing item and new item should be created in route POST | items). But, If I use the second line, there is maybe the problem that it is not idempotent as created_at would be changed on each hit. (depends on implementation really, but look at this from REST perspective).
Should I use this instead (replace Route::resource with Route::post)?
Is something wrong with this approach?