vendredi 4 octobre 2019

Verification of payments and ceiling of trainings in Laravel

My goal is that when I encode a student for a payment. He (student) can follow 2 trainings per payment. (this is the ceiling - 1 payment = 2 trainings)

In my form Payment, I encode a student for example Menier.

enter image description here

The student is entitled to two trainings, (this is the ceiling)

In my form Training: I encode 2 trainings for the student Menier.

enter image description here

My first question: how can I block the number of trainings by two?

(so, if I encode another training, it must block!)

My second queston, if I encode 2 payments for the same student. The student is entitled to 4 trainings. How to create this type of algorithm?

enter image description here

Here is my code for now, I know it's not a lot...

Controller Training

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

Controlle Payment

public function store(Request $request)
    {
        $request->validate([
                'date_payment' => 'required',
                'fk_student' => 'required'


        ]);

        $date_payment = $request->get('date_payment'); 
        $fk_student = $request->get('fk_student');

Do you have an idea of how I could solve my problems, I am still a beginner in laravel.

Thank you for your time.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire