I am making a random website(own project for uni) that stores info about recent sports games and teams(team names and player names are made up) and I’d like to find out how can I(or what is the best way) to return player names that belong to their team.
Code example from .blade
<details>
<summary class="displayTeams"> Pueblo Thrashers </summary>
<div class="allplayers">
@foreach($PTh as $PTplayer)
<p class="displayTeamsPlayer">{{$PTplayer->Name}} {{$PTplayer->LastName}} </p>
@endforeach
</div>
</details>
Code example from my controller:
function showPlayers(){
$PT = DB::table('players')->where('Team_ID', '1')->get();
$RK = DB::table('players')->where('Team_ID', '2')->get();
return view('WHL', ['PTh' => $PT], ['RKi' => $RK]);
I have 6 more teams that I need to get players from, what’s the best possible way to do that?