vendredi 18 octobre 2019

checking date payment for my method update()

In my method update() I have to checking the date_payment and la date_seance. if the date_payment is greater than the date_seance, I must have an error message

My checking does not work ... I did a dump..

Training::find($id); 

My dateFormat is null? It's perhaps the problem?

public function update(Request $request, $id)

    {

        $request->validate([

                'date_seance' => 'required',

                'hour_start' => 'required',

                'hour_end' => 'required',

                'fk_motorbike' => 'required',

                'fk_former' => 'required',

                'fk_student' => 'required'

        ]);



       $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');



       $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();
   }

    }



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2BnGkPM
via IFTTT

Aucun commentaire:

Enregistrer un commentaire