lundi 1 février 2021

Compare date time in Laravel eloquent

I have start and end date time column in database

start_date             end_date             contact
2021-01-25 17:30:00    2021-01-25 20:30:00   xxxxxxxxx
2021-01-27 17:30:00    2021-01-28 19:30:00   xxxxxxxxx

Now i'm trying to get records which exists between these two date time, it should match mobile number also.I'm using below query but it is not filtering record

   $date = date('Y-m-d H:i:s', strtotime($request->date));
   $contact_number=$request->contact_number;

$event=Event::where(function ($query)use($date,$contact_number){
    $query->where('start_date', '>=', $date)->where('end_date', '<=', $date);})->where('contact',$contact_number)->paginate(5);  


via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire