Ekapp/skolehjem/database/seeds/RoleSeeder.php

35 lines
719 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 = [
"administrator" => "Admin",
"user" => "Userstuff",
];
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();
}
}
}
}