Я новичок в laravel и получил эту ошибку
Свойство [stats] не существует в этом экземпляре коллекции.(Представление: C: \ xampp \ htdocs \ enginepoker2 \ resources \ views \ pages \ Players.blade.php)
это в Players.blade.php
@foreach ($player_stats->stats as $player_stat)
<tr class="gradeX">
<td><a href="">{{ $player_stat->username }}</a></td>
<td>{{ $player_stat->country }}</td>
<td>{{ $player_stat->rank }}</td>
<td class="center"><a href="#" class="name" data-name="winpot" data-pk="{{ $player_stat->ID }}" data-type="text" data-url="{{ route('updatePlayer') }}">{{ number_format($player_stat->winpot, 2, ',', '.') }}</a></td>
<td class="center"><a href="#" class="name" data-name="freeGames" data-pk="{{ $player_stat->ID }}" data-type="text" data-url="{{ route('updatePlayer') }}">{{ $player_stat->freeGames }}</a></td>
<td class="center"><a href="#" class="name" data-name="transferLimit" data-pk="{{ $player_stat->ID }}" data-type="text" data-url="{{ route('updatePlayer') }}">{{ number_format($player_stat->transferLimit, 2, ',', '.') }}</a></td>
</tr>
@endforeach
это в контроллере
use App\players;
use Illuminate\Http\Request;
class playerController extends Controller
{
public function index()
{
$player_stats = players::where('bot', '=', '0')->orderBy('ID', 'DESC')->limit('500')->get();
return view('pages.players', [ 'player_stats'=>$player_stats]);
}
}
это в модели игроков
namespace App;
use Illuminate\Database\Eloquent\Model;
class players extends Model
{
protected $player = 'players';
public function stats()
{
return $this->belongsTo(stats::class);
}
}
это в статистике модели
namespace App;
use Illuminate\Database\Eloquent\Model;
class stats extends Model
{
protected $player = 'stats';
public function players()
{
return $this->hasMany(players::class);
}
}