I'm having an error when seeding to the database using laravel 5.4 the error message is below and there is my users class and my seeder class. What is happening is that one record is being inserted at a time when calling db:seed but after the first call it says [Symfony\Component\Debug\Exception\FatalThrowableError]
rest below
[Symfony\Component\Debug\Exception\FatalThrowableError]
Call to a member function perms() on null
Model User
`<?php
namespace App;
use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Zizaco\Entrust\Traits\EntrustUserTrait;
class User extends Authenticatable
{
use EntrustUserTrait;
use Notifiable;
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'name', 'email', 'password',
];
/**
* The attributes that should be hidden for arrays.
*
* @var array
*/
protected $hidden = [
'password', 'remember_token',
];
public function Role(){
return $this->belongsTo('\App\Role', 'id');
}
}`
Model Role
`<?php
namespace App;
use Zizaco\Entrust\EntrustRole;
class Role extends EntrustRole
{
protected $fillable = ['name', 'display_name', 'description', 'level'];
public function User(){
return $this->hasMany('\App\User');
}
}`
Seeder RoleTableSeeder
`<?php
use Illuminate\Database\Seeder;
class RolesTableSeeder extends Seeder
{
/**
Run the database seeds.
@return void
*/
public function run()
{
DB::table('roles')->delete();
I'm having an error when seeding to the database using laravel 5.4 the error message is below and there is my users class and my seeder class. What is happening is that one record is being inserted at a time when calling db:seed but after the first call it says [Symfony\Component\Debug\Exception\FatalThrowableError] rest below
[Symfony\Component\Debug\Exception\FatalThrowableError] Call to a member function perms() on null Model User `<?php
namespace App;
use Illuminate\Notifications\Notifiable; use Illuminate\Foundation\Auth\User as Authenticatable; use Zizaco\Entrust\Traits\EntrustUserTrait;
class User extends Authenticatable { use EntrustUserTrait; use Notifiable;
}`
Model Role `<?php
namespace App;
use Zizaco\Entrust\EntrustRole;
class Role extends EntrustRole { protected $fillable = ['name', 'display_name', 'description', 'level']; public function User(){ return $this->hasMany('\App\User'); } }`
Seeder RoleTableSeeder `<?php
use Illuminate\Database\Seeder;
class RolesTableSeeder extends Seeder { /**
@return void */ public function run() { DB::table('roles')->delete();
} }`