Ekapp/skolehjem/database/seeds/RoleSeeder.php

37 lines
721 B
PHP

<?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();
}
}
}
}