Besoin d'aide ?

Comment réaliser un calcul avec le contenu de deux tables?

Avatar de AlexandreCarignan
AlexandreCarignan

Bonjour, j'avance tranquillement mon site, maintenant que je peux afficher le contenu des tables, j'aimerais maintenant automatiser certains calculs.

voici ce que j'aimerais réaliser $careerPhy = {{ $character->character_career_physic }}; $phybonus = {{ $character->character_career_physic_bonus }}; $phypenalty = {{ $character->character_career_physic_penalty }}; $careerPhyT = $careerPhy + $phybonus - $phypenalty;

Je crois que je dois travailler dans le CharacterController.php

 /**
     * Display the specified resource.
     *
     * @param  \App\Models\Character  $character
     * @return \Illuminate\Http\Response
     */
    public function show($id)
    {
        $careerPhy = {{ $character->character_career_physic }};
        $phybonus = {{ $character->character_career_physic_bonus }};
        $phypenalty = {{ $character->character_career_physic_penalty }};
        $careerPhyT = $careerPhy + $phybonus - $phypenalty;
        return view('character.show', [
            'character' => Character::findOrFail($id)

        ]);
    }

Voici mon code d'affichage de la vue.


<tbody>
     <tr>
             <th scope="row" style="width: 55%" height="35px">{{ $character->character_career_name }}</th>
                  <td style="width: 5%" height="35px">{{ $careerPhyT }}</td>
                  <td style="width: 5%" height="35px">{{ $character->character_career_physic_bonus }}</td>
                  <td style="width: 5%" height="35px">{{ $character->character_career_physic_penalty }}</td>
                  <td style="width: 5%" height="35px">{{ $character->character_career_mental }}</td>
                  <td style="width: 5%" height="35px">{{ $character->character_career_mental_bonus }}</td>
                  <td style="width: 5%" height="35px">{{ $character->character_career_mental_penalty }}</td>
                  <td style="width: 5%" height="35px">{{ $character->character_career_reaction }}</td>
                  <td style="width: 5%" height="35px">{{ $character->character_career_reaction_bonus }}</td>
                  <td style="width: 5%" height="35px">{{ $character->character_career_reaction_penalty }}</td>
      </tr>

Merci Alexandre.

Posté il y a 8 mois
Avatar de AlexandreCarignan
AlexandreCarignan

Résolu en réalisant le calcul dans les braquettes blade

<td style="width: 5%" height="35px"> {{ $character->character_career_physic + $character->character_career_physic_bonus - $character->character_career_physic_penalty }}</td>
Posté il y a 8 mois
Avatar de AlexandreCarignan
AlexandreCarignan

Résolu en réalisant le calcul dans les braquettes blade

<td style="width: 5%" height="35px"> {{ $character->character_career_physic + $character->character_career_physic_bonus - $character->character_career_physic_penalty }}</td>
Posté il y a 8 mois

Vous ne pouvez pas répondre à ce sujet.