forked from miguel456/rbrecruiter
Refactored seeders
This commit is contained in:
parent
a206782187
commit
0c667d74ef
|
@ -36,7 +36,7 @@ class PermissionSeeder extends Seeder
|
||||||
{
|
{
|
||||||
app()[\Spatie\Permission\PermissionRegistrar::class]->forgetCachedPermissions();
|
app()[\Spatie\Permission\PermissionRegistrar::class]->forgetCachedPermissions();
|
||||||
|
|
||||||
//
|
|
||||||
$user = Role::create(
|
$user = Role::create(
|
||||||
[
|
[
|
||||||
'name' => 'user',
|
'name' => 'user',
|
||||||
|
@ -61,34 +61,40 @@ class PermissionSeeder extends Seeder
|
||||||
|
|
||||||
// Spatie wildcard permissions (same concept of MC permissions)
|
// Spatie wildcard permissions (same concept of MC permissions)
|
||||||
|
|
||||||
Permission::create(['name' => 'applications.submit']);
|
$permissions = [
|
||||||
Permission::create(['name' => 'applications.stages.deny']);
|
'applications.submit',
|
||||||
Permission::create(['name' => 'applications.stages.approve']);
|
'applications.stages.deny',
|
||||||
Permission::create(['name' => 'applications.view.all']);
|
'applications.stages.approve',
|
||||||
Permission::create(['name' => 'applications.view.own']);
|
'applications.view.all',
|
||||||
Permission::create(['name' => 'applications.vote']);
|
'applications.view.own',
|
||||||
Permission::create(['name' => 'appointments.schedule']);
|
'applications.vote',
|
||||||
Permission::create(['name' => 'appointments.schedule.edit']);
|
'appointments.schedule',
|
||||||
Permission::create(['name' => 'appointments.schedule.cancel']);
|
'appointments.schedule.edit',
|
||||||
Permission::create(['name' => 'applications.*']);
|
'appointments.schedule.cancel',
|
||||||
Permission::create(['name' => 'appointments.*']);
|
'applications.*',
|
||||||
|
'appointments.*',
|
||||||
|
|
||||||
Permission::create(['name' => 'profiles.view.others']);
|
'profiles.view.others',
|
||||||
Permission::create(['name' => 'profiles.edit.others']);
|
'profiles.edit.others',
|
||||||
|
|
||||||
Permission::create(['name' => 'admin.userlist']);
|
'admin.userlist',
|
||||||
Permission::create(['name' => 'admin.stafflist']);
|
'admin.stafflist',
|
||||||
Permission::create(['name' => 'admin.hiring.forms']);
|
'admin.hiring.forms',
|
||||||
Permission::create(['name' => 'admin.hiring.formbuilder']);
|
'admin.hiring.formbuilder',
|
||||||
Permission::create(['name' => 'admin.hiring.vacancy']);
|
'admin.hiring.vacancy',
|
||||||
Permission::create(['name' => 'admin.hiring.vacancy.edit,delete']);
|
'admin.hiring.vacancy.edit,delete',
|
||||||
Permission::create(['name' => 'admin.notificationsettings']);
|
'admin.notificationsettings',
|
||||||
Permission::create(['name' => 'admin.notificationsettings.edit']);
|
'admin.notificationsettings.edit',
|
||||||
Permission::create(['name' => 'admin.hiring.*']);
|
'admin.hiring.*',
|
||||||
Permission::create(['name' => 'admin.notificationsettings.*']);
|
'admin.notificationsettings.*',
|
||||||
Permission::create(['name' => 'admin.maintenance.logs.view']);
|
'admin.maintenance.logs.view',
|
||||||
|
'admin.developertools.use',
|
||||||
|
];
|
||||||
|
|
||||||
Permission::create(['name' => 'admin.developertools.use']);
|
foreach ($permissions as $permission)
|
||||||
|
{
|
||||||
|
Permission::create(['name' => $permission]);
|
||||||
|
}
|
||||||
|
|
||||||
$user->givePermissionTo([
|
$user->givePermissionTo([
|
||||||
'applications.submit',
|
'applications.submit',
|
||||||
|
|
|
@ -23,6 +23,7 @@ namespace Database\Seeders;
|
||||||
|
|
||||||
use Illuminate\Database\Seeder;
|
use Illuminate\Database\Seeder;
|
||||||
use Spatie\Permission\Models\Permission;
|
use Spatie\Permission\Models\Permission;
|
||||||
|
use Spatie\Permission\Models\Role;
|
||||||
|
|
||||||
class TeamSeeder extends Seeder
|
class TeamSeeder extends Seeder
|
||||||
{
|
{
|
||||||
|
@ -33,42 +34,43 @@ class TeamSeeder extends Seeder
|
||||||
*/
|
*/
|
||||||
public function run()
|
public function run()
|
||||||
{
|
{
|
||||||
Permission::create([
|
$teamUserPermissions = [
|
||||||
'name' => 'teams.user.view.own',
|
|
||||||
]);
|
'teams.files.view',
|
||||||
|
'teams.files.upload',
|
||||||
|
'teams.files.download',
|
||||||
|
'teams.files.delete',
|
||||||
|
];
|
||||||
|
|
||||||
|
// Some of these perms also check whether the user is a member or owner to determine access to resources.
|
||||||
|
$teamPermissions = [
|
||||||
|
|
||||||
|
'teams.view',
|
||||||
|
'teams.create',
|
||||||
|
'teams.update',
|
||||||
|
'teams.invite'
|
||||||
|
];
|
||||||
|
|
||||||
|
$admin = Role::where('name', 'admin')->first();
|
||||||
|
$reviewer = Role::where('name', 'reviewer')->first();
|
||||||
|
|
||||||
|
foreach($teamPermissions as $permission)
|
||||||
|
{
|
||||||
|
foreach ($teamUserPermissions as $userPermission)
|
||||||
|
{
|
||||||
|
Permission::create(['name' => $permission]);
|
||||||
|
Permission::create(['name' => $userPermission]);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$admin->givePermissionTo($teamPermissions);
|
||||||
|
$reviewer->givePermissionTo($teamUserPermissions);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Permission::create([
|
|
||||||
'name' => 'teams.admin.view.all',
|
|
||||||
]);
|
|
||||||
|
|
||||||
// Has access to the teams feature
|
|
||||||
Permission::create([
|
|
||||||
'name' => 'teams.view',
|
|
||||||
]);
|
|
||||||
|
|
||||||
Permission::create([
|
|
||||||
'name' => 'teams.admin.create',
|
|
||||||
]);
|
|
||||||
Permission::create([
|
|
||||||
'name' => 'teams.admin.delete',
|
|
||||||
]);
|
|
||||||
Permission::create([
|
|
||||||
'name' => 'teams.user.join',
|
|
||||||
]);
|
|
||||||
Permission::create([
|
|
||||||
'name' => 'teams.user.leave',
|
|
||||||
]);
|
|
||||||
Permission::create([
|
|
||||||
'name' => 'teams.admin.vacancies.assign',
|
|
||||||
]);
|
|
||||||
Permission::create([
|
|
||||||
'name' => 'teams.admin.vacancies.unassign',
|
|
||||||
]);
|
|
||||||
Permission::create([
|
|
||||||
'name' => 'teams.admin.applications.changeteam',
|
|
||||||
]);
|
|
||||||
Permission::create([
|
|
||||||
'name' => 'teams.members.groupchat',
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue