L
L
lolrofl012018-12-16 21:04:53
Laravel
lolrofl01, 2018-12-16 21:04:53

How to add a condition inside an eloquent query?

Is it possible to do this:

->select(...)
->where('one',  1)
 >where('two',  2)
//Сюда добавить условие типа
if( 1 == 1 ) {
->where('three' , 3)
}
->get();

That is, if the condition satisfies - insert another where into the query, if not - then no. Is it possible to do something like this?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
J
JhaoDa, 2018-12-16
@lolrofl01

Get started. Read. Documentation.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question