Ekapp/skolehjem/database/seeds/RoleSeeder.php

35 lines
724 B
PHP
Raw Normal View History

2020-07-28 08:22:45 +00:00
<?php
use Illuminate\Database\Seeder;
class RoleSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$roles = [
2020-07-29 11:28:25 +00:00
"Administrator" => "Administrator",
"User" => "Bruger",
2020-07-28 08:22:45 +00:00
];
foreach ($roles as $key => $value) {
try {
if (\Spatie\Permission\Models\Role::findByName($key))
continue;
} catch (Exception $e) {
$permission = new \Spatie\Permission\Models\Role();
$permission->name = $key;
$permission->description = $value;
$permission->save();
}
}
}
}