The question I have come up with is simple;
I make a query with \DB
$data = \DB::table('users')->select($lo_que_sea)
->where(['vacations.aceptado' => $filtro])
->get();
I want to make a condition on that where so that if $filtro
is null, do not do that where something like this:
$data = \DB::table('users')->select(lo que sea)
if($filtro != null){
->where(['vacations.aceptado' => $filtro])
->get();
}else{
->get();
}
If I do not just do the ->get()
, right now I use this query dynamically in two methods, but if I could do the conditional I would not have to create another method or another query. To see all the inserts.
Greetings and thanks.