dimanche 15 septembre 2019

memorize the total price of my trainings?

In my page Training I enter the values differents: date_seance, hour_start, hour_end, fk_motorbike, fk_former, fk_student, fk_typeseance.

enter image description here

My problem: In my page Payment, I would like to retrieve the total of my trainings for the student Dion. So, here I have to get 230 $. I don't know how to make this?

enter image description here

Here is my architecture.

enter image description here

Here is my code, but I admit to being really stuck...

(1) I have to get the training price (table type seance)

(2) But how to calculate several trainings of the same student?

Controller Payment:

public function store(paiementRequest $request)
{

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



    $calculus = Typeseance::where('fk_student', $request->get('fk_student'))
    $data = $request->all(); 
    $data['total'] = $request->price + ???? 
            Payment::create($data);
            return redirect()->route('payments.index')
                ->with('success', 'Add');
        }

Thank you for your help.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire