vmailadmin/database/seeds/RolesTableSeeder.php

56 lines
1.5 KiB
PHP
Raw Permalink Normal View History

2020-05-23 15:20:01 +02:00
<?php
use Illuminate\Database\Seeder;
class RolesTableSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
/*
* Role Types
*
*/
$RoleItems = [
[
'name' => 'Admin',
'slug' => 'admin',
'description' => 'Admin Role',
'level' => 5,
],
[
'name' => 'User',
'slug' => 'user',
'description' => 'User Role',
'level' => 1,
],
[
'name' => 'Unverified',
'slug' => 'unverified',
'description' => 'Unverified Role',
'level' => 0,
],
];
/*
* Add Role Items
*
*/
foreach ($RoleItems as $RoleItem) {
$newRoleItem = config('roles.models.role')::where('slug', '=', $RoleItem['slug'])->first();
if ($newRoleItem === null) {
$newRoleItem = config('roles.models.role')::create([
'name' => $RoleItem['name'],
'slug' => $RoleItem['slug'],
'description' => $RoleItem['description'],
'level' => $RoleItem['level'],
]);
}
}
}
}