35 lines
724 B
PHP
35 lines
724 B
PHP
<?php
|
|
|
|
use Illuminate\Database\Seeder;
|
|
|
|
class RoleSeeder extends Seeder
|
|
{
|
|
/**
|
|
* Run the database seeds.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function run()
|
|
{
|
|
$roles = [
|
|
"Administrator" => "Administrator",
|
|
"User" => "Bruger",
|
|
];
|
|
|
|
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();
|
|
}
|
|
}
|
|
}
|
|
}
|