Fixed organisation permission seeds & added an organisations admin role

This commit is contained in:
2022-02-08 09:36:06 +00:00
parent 4bd115ba4d
commit 76442dbd4c
2 changed files with 71 additions and 6 deletions

View File

@@ -0,0 +1,48 @@
<?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 "organisation administrators", who can basically do anything related to organisations and their members.',
]),
];
}
}