.... and there is no unique constraints on your database tables. Right ?
Oct 8, 2019
3
Level 1
eloquant date & hours
I am stuck about a problem concerning the hours en laravel.
In my form Training, I have several recordings.

For example, I want to add an other recording
On 20/09/2019 From 08:00 to 10:00

When, I confirm, I have a duplicate system...

The problem is that I don't have a recording for on 20/09/2019 From 08:00 to 10:00
In fact, my code blocks the hours even if the dates are different, how can I solve this problem?
$date_seance = Carbon::parse($request->get('date_seance'))->format('Y-m-d');
$hour_start = $request->get('hour_start');
$hour_end = $request->get('hour_end');
$fk_motorbike = $request->get('fk_motorbike');
$fk_student = $request->get('fk_student');
$fk_former = $request->get('fk_former');
$fk_typeseance = $request->get('fk_typeseance');
$conflictTraining1 = Training::where('fk_motorbike', $request->get('fk_motorbike'))
->whereDate('date_seance', "=" , Carbon::parse($date_seance))
->where('hour_start', "<=" , $request->get('hour_start'))
->where('hour_end', ">=" , $request->get('hour_end'))
->where('fk_former', $request->get('fk_former'))
->first();
$conflictTraining2 = Training::where('fk_motorbike', $request->get('fk_motorbike'))
->where('hour_start', "<=" , $request->get('hour_start'))
->where('hour_end', ">=" , $request->get('hour_end'))
->where('fk_former', $request->get('fk_former'))
->first();
Please or to participate in this conversation.