samedi 7 septembre 2019

comparison between seance and payment

I have a question concerning the payment verification.

For example, the student Leonard pays a seance on 09/09/2019 only.

enter image description here

In my form Training, I see that I can add several seances ????

enter image description here

Can I block this?

enter image description here

For information, to join the table training and payment I do this:

Model Payment

public function payments(){

        return $this->hasManyThrough(
            'App\Payment',
            'App\Training',
            'fk_type_seance',
            'fk_training',
            'id',
            'id'
        );
    }

In the file index.training I have this:

@foreach($trainings as $training)
        <tr>
        <td></td>
        <td></td>
        <td></td>
        <td></td>
        <td></td>
        <td></td>
        <td> </td> 

Here is how I get the variable date_payment

enter image description here

I have to do how to limit the seances? Because it's for now illimited... the number of seances is not taken into account with the payment.

I have so far this???

public function store(Request $request)
    {
        $request->validate([
                'date_seance' => 'required',
                'hour_start' => 'required',
                'hour_end' => 'required',
                'fk_motorbike' => 'required',
                'fk_former' => 'required',
                'fk_student' => 'required'


        ]);


       $date_start = $request->get('date_seance'); 
       $hour_start = $request->get('hour_start'); 
       $hour_end = $request->get('hour_end'); 
       $fk_motorbike = $request->get('fk_motorbike');
       $fk_former = $request->get('fk_former');


       $conflictPayment = Training::where('fk_student', $fk_student)  
        ->where('number_seance', "!=" , $request->get('fk_student')) 
        ->first();  

        if(isset($conflictPayment)){
        return redirect()->route('trainings.index')
        ->with('error', 'You have reached the limit of your sessions ! ');
        }

}

Thank you for your help.



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

Aucun commentaire:

Enregistrer un commentaire