S
S
sr362019-12-16 15:31:08
Laravel
sr36, 2019-12-16 15:31:08

How to create such a database query in Laravel?

Good afternoon.
I have a SQL query

select * from offers where category_id = 2 and (is_active = true or is_archive = true);

Now the line that pulls the necessary data looks like this
$offers = Offer::where('category_id',$activeCat->id)->get();

How to add additional conditions without using raw queries?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Ramm, 2019-12-16
@sr36

$offers = Offer::where(function($query) {
    $query->where('is_active', true)->orWhere('is_archive', true);
})->where('category_id',$activeCat->id)->get();

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question