Added RoleSeeder.php
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
<?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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user