Monday, March 20, 2017

Laravel return model with user quantity

I have the following eloquent expression:

$user = JWTAuth::toUser($token);
return Item::where('type','craft')

In addition to the items data, I want to show the current user item quantity for each item received.

The item quantity of each user item is stored in my user_items table, with the following structure:

id | user_id | item_id | quantity

Any ideas how I can return the quantity of each item received in my eloquent Item model?



via TheUnreal

Advertisement