Lager-v3/database/seeders/RoleSeeder.php

32 lines
656 B
PHP
Raw Permalink Normal View History

2022-09-28 07:38:08 +00:00
<?php
namespace Database\Seeders;
use App\Models\Permission;
use App\Models\Role;
use Illuminate\Database\Seeder;
class RoleSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$items = [
['name' => 'Administrator'],
['name' => 'Elev'],
['name' => 'Underviser'],
['name' => 'Helpdesk'],
['name' => 'Server'],
];
foreach ($items as $item) {
Role::create($item);
}
Role::where('name', '=', 'Administrator')->first()->permissions()->sync(Permission::all());
}
}