I have to do a checking between the payment date and the seance date in my method store(). The method store() is OK!
$datePayment = Payment::where('fk_student', $request->get('fk_student'))
->whereDate('date_payment', ">" , $date_seance)
->first();
if(isset($datePayment)){
return redirect()->route('trainings.index')
->with('error', 'There is a problem with the payment date! ');
}
My problem is in my function update(), I am stuck. When, I change the value of the date_seance, there is no checking.
$datePayment = Payment::where('fk_student', $request->get('fk_student'))
->whereDate('date_payment', ">" , $date_seance)
->first();
if(isset($datePayment)){
return redirect()->route('trainings.index')
->with('error', 'There is a problem with the payment date! ');
}
else{
$trainings = Training::find($id);
$trainings->date_seance = $request->get('date_seance');
...
$trainings->save();
return redirect()->route('trainings.index')
->with('success', 'Update!')->withInput();
}
I know my problem is here in the condition:
if(isset($datePayment)){
return redirect()->route('trainings.index')
->with('error', 'There is a problem with the payment date! ');
}
Thank you for your help.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire