for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php namespace Arcanesoft\Auth\Seeds;
use Arcanesoft\Auth\Bases\Seeder;
use Arcanesoft\Auth\Models\Permission;
use Arcanesoft\Auth\Models\Role;
use Carbon\Carbon;
/**
* Class RolesSeeder
*
* @package Arcanesoft\Auth\Seeds
* @author ARCANEDEV <[email protected]>
*/
abstract class RolesSeeder extends Seeder
{
/* ------------------------------------------------------------------------------------------------
| Main Functions
| ------------------------------------------------------------------------------------------------
* Seed roles.
* @param array $roles
public function seed(array $roles)
$roles = $this->prepareRoles($roles);
Role::insert($roles);
insert()
Arcanesoft\Auth\Models\Role
insertAndSetId()
This check marks calls to methods that do not seem to exist on an object.
This is most likely the result of a method being renamed without all references to it being renamed likewise.
$this->syncAdminRole();
}
| Other Functions
* Prepare roles to seed.
* @return array
protected function prepareRoles(array $roles)
$now = Carbon::now();
foreach ($roles as $key => $role) {
$roles[$key]['slug'] = str_slug($role['name']);
$roles[$key]['is_active'] = isset($role['is_active']) ? $role['is_active'] : true;
$roles[$key]['is_locked'] = isset($role['is_locked']) ? $role['is_locked'] : true;
$roles[$key]['created_at'] = $now;
$roles[$key]['updated_at'] = $now;
return $roles;
* Sync the admin role with all permissions.
protected function syncAdminRole()
/** @var Role $admin */
$admin = Role::where('slug', 'administrator')->first();
$ids = Permission::all()->lists('id')->toArray();
$admin->permissions()->sync($ids);
This check marks calls to methods that do not seem to exist on an object.
This is most likely the result of a method being renamed without all references to it being renamed likewise.