49 lines
1.2 KiB
PHP
49 lines
1.2 KiB
PHP
<?php
|
|
|
|
/*
|
|
* AVSDev UF Organisations (https://avsdev.uk)
|
|
*
|
|
* @link https://git.avsdev.uk/avsdev/sprinkle-organisations
|
|
* @license https://git.avsdev.uk/avsdev/sprinkle-organisations/blob/master/LICENSE.md (LGPL-3.0 License)
|
|
*/
|
|
|
|
namespace UserFrosting\Sprinkle\Organisations\Database\Seeds;
|
|
|
|
use UserFrosting\Sprinkle\Account\Database\Models\Role;
|
|
use UserFrosting\Sprinkle\Core\Database\Seeder\BaseSeed;
|
|
|
|
/**
|
|
* Seeder for the organisation based roles.
|
|
*/
|
|
class OrganisationRoles extends BaseSeed
|
|
{
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
public function run()
|
|
{
|
|
$roles = $this->getRoles();
|
|
|
|
foreach ($roles as $role) {
|
|
// Don't save if already exist
|
|
if (Role::where('slug', $role->slug)->first() == null) {
|
|
$role->save();
|
|
}
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @return array Roles to seed
|
|
*/
|
|
protected function getRoles()
|
|
{
|
|
return [
|
|
new Role([
|
|
'slug' => 'organisations-admin',
|
|
'name' => 'Organisations Administrator',
|
|
'description' => 'This role is meant for administrators who can basically do anything related to any organisations.',
|
|
]),
|
|
];
|
|
}
|
|
}
|