Ich bin absolut ratlos durch dieses Problem, wo ich zahlreiche Tests ausprobiert habe, um die Ursache des Problems zu ermitteln. In meinem Controller weise ich meinem Array $players
eine Reihe von Werten zu. Wenn ich die Variable opprank
entferne, funktioniert alles gut. Wenn ich es aber enthalten, erhalte ich die Fehler Nachricht
nicht definierte Eigenschaft: stdClass :: $ opprank
Ich habe versucht, die Werte von $players
Dumping, wo der opprank Wert angezeigt wird wie erwartet. Ich habe versucht, es auf einen statischen Wert von "10" im Gegensatz zu dem DB-Wert einzustellen, aber den gleichen Fehler zu erhalten. Hoffentlich kann jemand vor Ort, wo ich falsch werde ...
SystemController.php
foreach ($teams as $team)
{
if ($players[$key]->team == $team->id)
{
// Replace Team ID with Team Short Code for Display Purposes
$players[$key]->team = $team->code;
$matchups = DB::table('schedule')->where('week', $week->value)->get();
foreach ($matchups as $matchup)
{
if ($team->id == $matchup->home_team)
{
$opp = DB::table('teams')->select('code', 'rank')->where('id', $matchup->away_team)->first();
$players[$key]->opponent = $opp->code;
$players[$key]->opprank = $opp->rank;
$players[$key]->status = 'Home';
}
else if ($team->id == $matchup->away_team)
{
$opp = DB::table('teams')->select('code', 'rank')->where('id', $matchup->home_team)->first();
$players[$key]->opponent = $opp->code;
$players[$key]->opprank = $opp->rank;
$players[$key]->status = 'Away';
}
}
}
}
foreach ($positions as $position)
{
if ($players[$key]->position == $position->id)
{
$players[$key]->position = $position->short_name;
}
}
}
return $players;
}
}
players.blade.php
<table class="table table-striped table-bordered table-hover" id="dt-players-all">
<thead>
<tr>
<th>Position</th>
<th>Player</th>
<th>Team</th>
<th>Opponent</th>
<th>Game</th>
<th>Opp. Rank</th>
<th>FPPG</th>
<th>Salary</th>
</tr>
</thead>
<tbody>
@foreach ($players as $player)
<tr>
<td>{{$player->position}}</td>
<td>{{$player->name}} <font color="red"><b>{{$player->injury_status}}</b></font></td>
<td>{{$player->team}}</td>
<td>{{$player->opponent}}</td>
<td>{{$player->status}}</td>
<td class="center">
@if ($player->opprank <= 10)
<font color="red"><b>{{$player->opprank}}</b></font>
@elseif ($player->opprank > 10 && ($player->opprank <= 20))
<b>{{$player->opprank}}</b>
@else
<b><font color="green">{{$player->opprank}}</font></b>
@endif
</td>
<td class="center">{{$player->fppg}}</td>
<td class="center">${{$player->salary}}</td>
</tr>
@endforeach
</tbody>
</table>
Welche Linie den Fehler verursacht? – Phil
Bitte versuchen Sie es als $ player [$ key] [opprank] = $ opp-> Rang; und alles. Probier diese. –
@Phil Es sagt seine Zeile 49 in der players.blade.php, aber das ist nur die leere Zeile über der if/elseif/else-Anweisung. –