I have a small problem in my dates. For example, I encoded the following date:
date training : 10/09/2019 | hour_start : 08:00 | hour_end : 10:00 | motorbike : 000001
Then, I want to encode for on 11/09/2019 the same informations
My checking compares only the hours (start & end) and no the date.
So, for my example, I have a blocking...
My problem is in my code
$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();
if(isset($conflictTraining)){
return redirect()->route('trainings.index')
->with('error', 'The training is already booked');
}
For information my hours are in format string is it a problem ?
Schema::create('trainings', function (Blueprint $table) {
$table->bigIncrements('id');
$table->date('date_seance');
$table->string('hour_start');
$table->string('hour_end');
Thank you for your help.
via Chebli Mohamed



Aucun commentaire:
Enregistrer un commentaire