<?php
use Illuminate\Database\Seeder;
use App\models\Permission;
use App\models\Role;
class RoleSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$role = Role::create([
'name' => 'super-admin',
'display_name' => 'Super Admin',
'description' => 'This will be one permission, that can not be assigned or created.'
]);
$permission = App\models\Permission::first()->where('name', 'super-admin')->first();
$role->attachPermission($permission);
}
}
I just tried it in tinker
>>> $permission = App\models\Permission::first();
=> App\models\Permission {#2923
id: 1,
name: "super-admin",
display_name: "Super Admin",
description: "This will be one permission, that can not be assigned or created.",
created_at: "2018-08-31 05:01:08",
updated_at: "2018-08-31 05:01:08",
}
>>> $role = App\models\Role::first();
=> App\models\Role {#2925
id: 1,
name: "super-admin",
display_name: "Super Admin",
description: "This will be one permission, that can not be assigned or modified.",
created_at: "2018-08-31 05:01:10",
updated_at: "2018-08-31 05:01:10",
}
>>> $role->attachPermission($permission);
PHP Error: Class 'App/Permission' not found in D:/work/www/myapp/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Concerns/HasRelationships.php on line 656
>>>
But getting error, as it is trying to search Permission model on App/ and not in App/models.
You can check more information on this . I asked it in stackoverflow, but it seems you are the correct person to help me here.
I tried doing this
I just tried it in tinker
But getting error, as it is trying to search Permission model on App/ and not in App/models.
You can check more information on this . I asked it in stackoverflow, but it seems you are the correct person to help me here.