Fixed organisation permission seeds & added an organisations admin role
This commit is contained in:
48
src/Database/Seeds/OrganisationRoles.php
Normal file
48
src/Database/Seeds/OrganisationRoles.php
Normal 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.',
|
||||
]),
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user