Before converting to Eloquent, you'd need to make an Item and Hired model to represent both of those tables. Have you?
Mar 13, 2019
8
Level 1
Convert Raw SQL to Eloquent
Hello, could you help me convert this SQL query to Eloquent:
SELECT item.id, hired.item_id, hired.quantity - item.quantity as quanity
FROM items item
join hireds hired on hired.item_id = item.id
WHERE item.quantity > hired.quantity
order by item.id;
Level 75
Does that give you correct results? If so, try and use a relation now using eloquent.
Also https://laracasts.com/series/laravel-from-scratch-2018 Is a free series.
2 likes
Please or to participate in this conversation.