2020-06-26 23:32:33 +00:00
|
|
|
<?php
|
2021-10-13 03:07:16 +00:00
|
|
|
/*
|
|
|
|
* Copyright © 2020 Miguel Nogueira
|
|
|
|
*
|
|
|
|
* This file is part of Raspberry Staff Manager.
|
|
|
|
*
|
|
|
|
* Raspberry Staff Manager is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* Raspberry Staff Manager is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with Raspberry Staff Manager. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2021-10-12 17:08:15 +00:00
|
|
|
namespace Database\Seeders;
|
2020-06-26 23:32:33 +00:00
|
|
|
|
|
|
|
use Illuminate\Database\Seeder;
|
|
|
|
use Spatie\Permission\Models\Permission;
|
|
|
|
use Spatie\Permission\Models\Role;
|
|
|
|
|
|
|
|
class PermissionSeeder extends Seeder
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Run the database seeds.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function run()
|
|
|
|
{
|
|
|
|
app()[\Spatie\Permission\PermissionRegistrar::class]->forgetCachedPermissions();
|
|
|
|
|
2021-10-13 01:57:00 +00:00
|
|
|
//
|
2020-06-26 23:32:33 +00:00
|
|
|
$user = Role::create(
|
|
|
|
[
|
2021-10-13 01:57:00 +00:00
|
|
|
'name' => 'user'
|
2020-06-26 23:32:33 +00:00
|
|
|
]
|
|
|
|
);
|
|
|
|
|
|
|
|
$reviewer = Role::create(
|
|
|
|
[
|
2021-10-13 01:57:00 +00:00
|
|
|
'name' => 'reviewer'
|
2020-06-26 23:32:33 +00:00
|
|
|
]
|
|
|
|
);
|
|
|
|
|
|
|
|
$hiringManager = Role::create(
|
|
|
|
[
|
2021-10-13 01:57:00 +00:00
|
|
|
'name' => 'hiringManager'
|
2020-06-26 23:32:33 +00:00
|
|
|
]
|
|
|
|
);
|
|
|
|
|
|
|
|
$admin = Role::create([
|
2021-10-13 01:57:00 +00:00
|
|
|
'name' => 'admin'
|
2020-06-26 23:32:33 +00:00
|
|
|
]);
|
|
|
|
|
|
|
|
// Spatie wildcard permissions (same concept of MC permissions)
|
|
|
|
|
2021-10-13 03:07:16 +00:00
|
|
|
$permissions = [
|
|
|
|
'applications.submit',
|
|
|
|
'applications.stages.deny',
|
|
|
|
'applications.stages.approve',
|
|
|
|
'applications.view.all',
|
|
|
|
'applications.view.own',
|
|
|
|
'applications.vote',
|
|
|
|
'appointments.schedule',
|
|
|
|
'appointments.schedule.edit',
|
|
|
|
'appointments.schedule.cancel',
|
|
|
|
'applications.*',
|
|
|
|
'appointments.*',
|
|
|
|
|
|
|
|
'profiles.view.others',
|
|
|
|
'profiles.edit.others',
|
|
|
|
|
|
|
|
'admin.userlist',
|
|
|
|
'admin.stafflist',
|
|
|
|
'admin.hiring.forms',
|
|
|
|
'admin.hiring.formbuilder',
|
|
|
|
'admin.hiring.vacancy',
|
|
|
|
'admin.hiring.vacancy.edit,delete',
|
|
|
|
'admin.notificationsettings',
|
|
|
|
'admin.notificationsettings.edit',
|
|
|
|
'admin.hiring.*',
|
|
|
|
'admin.notificationsettings.*',
|
|
|
|
'admin.maintenance.logs.view',
|
|
|
|
'admin.developertools.use',
|
|
|
|
];
|
|
|
|
|
|
|
|
foreach ($permissions as $permission)
|
|
|
|
{
|
|
|
|
Permission::create(['name' => $permission]);
|
|
|
|
}
|
2020-06-26 23:32:33 +00:00
|
|
|
|
|
|
|
$user->givePermissionTo([
|
|
|
|
'applications.submit',
|
|
|
|
'applications.view.own',
|
2021-10-13 01:57:00 +00:00
|
|
|
'profiles.view.others'
|
2020-06-26 23:32:33 +00:00
|
|
|
]);
|
|
|
|
|
|
|
|
// Able to view applications and vote on them once they reach the right stage, but not approve applications up to said stage
|
|
|
|
$reviewer->givePermissionTo([
|
|
|
|
'applications.view.all',
|
2021-10-13 01:57:00 +00:00
|
|
|
'applications.vote'
|
2020-06-26 23:32:33 +00:00
|
|
|
]);
|
|
|
|
|
|
|
|
$hiringManager->givePermissionTo('appointments.*', 'applications.*', 'admin.hiring.*');
|
|
|
|
|
|
|
|
$admin->givePermissionTo([
|
|
|
|
'appointments.*',
|
|
|
|
'admin.userlist',
|
|
|
|
'admin.stafflist',
|
|
|
|
'admin.hiring.*',
|
|
|
|
'admin.notificationsettings.*',
|
|
|
|
'profiles.view.others',
|
|
|
|
'profiles.edit.others',
|
2021-10-13 01:57:00 +00:00
|
|
|
'admin.maintenance.logs.view'
|
2020-06-26 23:32:33 +00:00
|
|
|
]);
|
|
|
|
}
|
|
|
|
}
|