I want to seed my db that shows me this error:
Call to undefined method Illuminate\Database\Query\Builder::passengers()
this is databse seeder:
public function run()
{
// $this->call(UsersTableSeeder::class);
factory(App\Airport::class, 5)->create();
factory(App\Flight::class, 10)->create()->each(function ($flight) {
factory(App\Customer::class, 100)->make()->each(function ($customer) use ($flight) {
$flight->passengers()->save($customer);
});
});
}
Customer Model:
namespace App;
use Illuminate\Database\Eloquent\Model;
class Customer extends Model
{
public function Flights()
{
return $this->belongsToMany('App\Customer');
}
}
Flight Model
class Flight extends Model
{
//
public function arrivalAirport(){
return $this->belongsto('App\Airport','arrivalAirport_id');
}
public function departureAirport(){
return $this->belongsto('App\Airport','departureAirport');
}
public function passenger(){
return $this->belongsto('App\Customer','flight_customer');
}
}
who know where this can come ?
Flightmodel? - Rwd