Question

I wish to know how to write the following in laravel:

SELECT * FROM items WHERE item_id = $id AND item_category = $cat AND item_price = $price;

$id, $cat and $price are dynamically passed unto the query. Thanks.

Was it helpful?

Solution

Eloquent

Item::where('item_id', $id)
->where('item_category', $cat)
->where('item_price', $price)
->get();

Fluent

DB::table('items')
->where('item_id', $id)
->where('item_category', $cat)
->where('item_price', $price)
->get();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top