select query laravel with dates

0

I need to prevent entering a new event if there was already another previous one with dates with time in that range. For this I tried to use the typical where with < = start and > = end but it did not work and as a last attempt I used this but it did not work either.

$eventexist =DB::table('events')->where('doctor_id', $input['doctor_id'])->whereBetween('start', array($input['start'], $input['end']))->whereBetween('end', array($input['start'], $input['end']))->first();

That is, when I have an event with start 01-01-2017 3:00 and I finish 01-01-2017 4:00 if in the table there is a start record 01-01-2017 3:30 and I finish 01 -01-2017 3:45 should not be inserted.

    
asked by Guido 30.01.2017 в 04:34
source

0 answers