moealmaw / sport

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Fix

Add the following relation to the \App\Team model

  ...
  public function positions() {
    return $this->hasManyThrough(\App\Position::class, \App\Sport::class, 'id', 'sport_id', 'sport_id');
  }
  ...

Check the results routes/web.php

Route::get('/', function () {
  $teams = \App\Team::with('positions', 'positions.players')->get();
  return $teams;
});

Run the example

Rename .env-sample into .env

Add database connection details (use an newly created database)

Migrate & Seed the database

php artisan migrate --seed

About


Languages

Language:PHP 99.4%Language:Vue 0.6%