Raw query to Laravel Query
SELECT * FROM plans_subscriptions WHERE starts_on BETWEEN "2019-07-30" AND "2019-07-26" or expires_on BETWEEN "2019-07-20" AND "2019-07-22"
Raw query to Laravel Query
SELECT * FROM plans_subscriptions WHERE starts_on BETWEEN "2019-07-30" AND "2019-07-26" or expires_on BETWEEN "2019-07-20" AND "2019-07-22"
If you want object response then use this :
PlansSubscriptions::whereBetween('starts_on', ["2019-07-30", "2019-07-26"]);
->orWhereBetween('expires_on', ["2019-07-20", "2019-07-22"]);
->get();
If you want array response then use this :
PlansSubscriptions::whereBetween('starts_on', ["2019-07-30", "2019-07-26"]);
->orWhereBetween('expires_on', ["2019-07-20", "2019-07-22"]);
->get()->toArray();
We can format the date like this :
$start = date("Y-m-d",strtotime($request->input('from_date')));
$end = date("Y-m-d",strtotime($request->input('to_date')));
and use that variable in query like this:
PlansSubscriptions::whereBetween('starts_on', [$start, $end]);
->orWhereBetween('expires_on', ["2019-07-20", "2019-07-22"]);
->get()->toArray();
plans_subscriptions WHERE starts_on BETWEEN "2019-06-02" AND "2019-07-26" and expires_on BETWEEN "2019-07-20" AND "2019-07-22"