Can SQL also run a query like the following? So first we will look at a value, accordingly we will look at other values.
SELECT * FROM IF WHERE `status` != 'true' ELSE WHERE `status_2` == 'false'
So how can we adapt this in laravel october CMS as below.
$query->whereHas('avaibleDates', function($q) {
if ( $q->where('start_date', '<=', 2) ) {
$q->where('status_id', '!=', 2);
}
});
So we want to run a query according to one situation and another query according to another situation.
According to your description, I do not quite understand what you want to do)). I think you need casts something like this:
$query->whereHas('avaibleDates', function($q) {
$q->where(function ($q) {
$q->where('start_date', '<=', 2)->where('status_id', '!=', 2);
});
// The following conditions
...
$q->orWhere(function ($q) {
$q->where('start_date', '>', 55)->where('status_id', '!=', 7);
});
...
});
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments