Zizaco / entrust

Role-based Permissions for Laravel 5
MIT License
6.05k stars 1.29k forks source link

Call to a member function perms() on null #837

Closed s5510886103 closed 7 years ago

s5510886103 commented 7 years ago

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 { /**

s5510886103 commented 7 years ago

created be create