dimanche 22 septembre 2019

planning between 2 models

I yet have a problem with my planning. My frist model is Revision with as informations following:

The date_revision_start on 12/09/2019 to 14/09/2019 then hour_start & hour_end from 07:00 to 09:00 and the bike 000001.

Below, I have no problem...

enter image description here

Now, in my model Training if I want to enter a training on 14/09/2019 from 10:00 to 12:00 for the bike 000001.

I have an error message ?? Normally, the recording is correct...

enter image description here

enter image description here

Do you have an idea for better compare my hour_start & hour_end?

$date_seance = $request->get('date_seance'); 
$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');

$conflictTraining = Training::where('fk_motorbike', $request->get('fk_motorbike'))  
        ->whereDate('date_seance', "=" , $date_seance)  
        ->where('hour_start', "<=" , $request->get('hour_start')) 
        ->where('hour_end', ">=" , $request->get('hour_end'))
        ->where('fk_former', $request->get('fk_former'))
        ->first();  

$conflictRevision = Revision::where('fk_motorbike', $fk_motorbike)
            ->whereDate('date_revision_start', "<=" , $date_seance)
            ->whereDate('date_revision_end', ">=", $date_seance)
            ->first();

$conflictRevision1 = Revision::where('fk_motorbike', $fk_motorbike)
            ->whereDate('date_revision_start', "<=" , $date_seance)
            ->where('hour_start', "<=" , $request->get('hour_start'))  
            ->where('hour_end', ">=" , $request->get('hour_end'))
            ->first();

$conflictRevision2 = Revision::where('fk_motorbike', $fk_motorbike)
            ->whereDate('date_revision_end', "<=" , $date_seance)
            ->where('hour_start', "<=" , $request->get('hour_start'))  
            ->where('hour_end', ">=" , $request->get('hour_end'))
            ->first();

$conflictFormer = Training::where('fk_former', $fk_former)  
            ->whereDate('date_seance', "=" , $date_seance)  
            ->where('hour_start', "<=" , $request->get('hour_start')) 
            ->where('hour_end', ">=" , $request->get('hour_end'))
            ->first();  

$conflictMotorbike = Training::where('fk_motorbike', $fk_motorbike)  
            ->whereDate('date_seance', "=" , $date_seance)  
            ->where('hour_start', "<=" , $request->get('hour_start')) 
            ->where('hour_end', ">=" , $request->get('hour_end'))
            ->first();  

Thank you for your help and your time.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire