refactor: code style changes
Signed-off-by: miguel456 <me@nogueira.codes>
This commit is contained in:
@@ -20,7 +20,6 @@
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class DatabaseSeeder extends Seeder
|
||||
|
@@ -19,7 +19,6 @@
|
||||
* along with Raspberry Staff Manager. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Facades\Options;
|
||||
@@ -41,7 +40,6 @@ class DefaultOptionsSeeder extends Seeder
|
||||
Options::setOption('notify_applicant_approved', true, 'Notify when an applicant is approved', 'notifications'); // done
|
||||
Options::setOption('notify_vacancystatus_change', false, 'Notify when a vacancy\'s status changes', 'notifications'); // done
|
||||
|
||||
|
||||
// added in 0.6.2
|
||||
Options::setOption('pw_security_policy', 'low', 'Describes the current password security policy.', 'app_security');
|
||||
Options::setOption('graceperiod', 7, '2FA Grace Period', 'app_security');
|
||||
@@ -51,10 +49,8 @@ class DefaultOptionsSeeder extends Seeder
|
||||
Options::setOption('requireGameLicense', true, 'Defines whether people need to validate their game license', 'app_security');
|
||||
|
||||
Options::setOption('currentGame', 'MINECRAFT', 'Defines what game we\'re working with', 'app_integration');
|
||||
|
||||
|
||||
Options::setOption('enable_slack_notifications', true, 'Enable slack notifications', 'notifications');
|
||||
Options::setOption('enable_email_notifications', true, 'Enable e-mail notifications', 'notifications');
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -34,7 +34,7 @@ class NewPermissions extends Seeder
|
||||
public function run()
|
||||
{
|
||||
$developer = Role::create([
|
||||
'name' => 'developer'
|
||||
'name' => 'developer',
|
||||
]);
|
||||
|
||||
$admin = Role::where('name', 'admin')->first();
|
||||
@@ -45,7 +45,5 @@ class NewPermissions extends Seeder
|
||||
$developer->givePermissionTo('admin.developertools.use');
|
||||
$admin->givePermissionTo('admin.settings.view');
|
||||
$admin->givePermissionTo('admin.settings.edit');
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -38,28 +38,28 @@ class PermissionSeeder extends Seeder
|
||||
//
|
||||
$user = Role::create(
|
||||
[
|
||||
'name' => 'user'
|
||||
'name' => 'user',
|
||||
]
|
||||
);
|
||||
|
||||
$staff = Role::create([
|
||||
'name' => 'staff'
|
||||
'name' => 'staff',
|
||||
]);
|
||||
|
||||
$reviewer = Role::create(
|
||||
[
|
||||
'name' => 'reviewer'
|
||||
'name' => 'reviewer',
|
||||
]
|
||||
);
|
||||
|
||||
$hiringManager = Role::create(
|
||||
[
|
||||
'name' => 'hiringManager'
|
||||
'name' => 'hiringManager',
|
||||
]
|
||||
);
|
||||
|
||||
$admin = Role::create([
|
||||
'name' => 'admin'
|
||||
'name' => 'admin',
|
||||
]);
|
||||
|
||||
// Spatie wildcard permissions (same concept of MC permissions)
|
||||
@@ -101,15 +101,14 @@ class PermissionSeeder extends Seeder
|
||||
'admin.developertools.use',
|
||||
];
|
||||
|
||||
foreach ($permissions as $permission)
|
||||
{
|
||||
foreach ($permissions as $permission) {
|
||||
Permission::create(['name' => $permission]);
|
||||
}
|
||||
|
||||
$user->givePermissionTo([
|
||||
'applications.submit',
|
||||
'applications.view.own',
|
||||
'profiles.view.others'
|
||||
'profiles.view.others',
|
||||
]);
|
||||
|
||||
$staff->givePermissionTo([
|
||||
@@ -121,7 +120,7 @@ class PermissionSeeder extends Seeder
|
||||
// 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',
|
||||
'applications.vote'
|
||||
'applications.vote',
|
||||
]);
|
||||
|
||||
$hiringManager->givePermissionTo('admin.viewAllAbsences', 'admin.manageAbsences', 'appointments.*', 'applications.*', 'admin.hiring.*');
|
||||
|
@@ -22,13 +22,11 @@
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Collection;
|
||||
use Spatie\Permission\Models\Permission;
|
||||
use Spatie\Permission\Models\Role;
|
||||
|
||||
class TeamSeeder extends Seeder
|
||||
{
|
||||
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
@@ -36,49 +34,43 @@ class TeamSeeder extends Seeder
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
$teamUserPermissions = [
|
||||
$teamUserPermissions = [
|
||||
|
||||
'teams.files.view',
|
||||
'teams.files.upload',
|
||||
'teams.files.download',
|
||||
'teams.files.delete',
|
||||
];
|
||||
'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 = [
|
||||
// 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'
|
||||
];
|
||||
'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)
|
||||
{
|
||||
$permCheck = Permission::where('name', $permission)->get()->all();
|
||||
foreach ($teamPermissions as $permission) {
|
||||
foreach ($teamUserPermissions as $userPermission) {
|
||||
$permCheck = Permission::where('name', $permission)->get()->all();
|
||||
|
||||
if (empty($permCheck))
|
||||
{
|
||||
Permission::create(['name' => $permission]);
|
||||
}
|
||||
if (empty($permCheck)) {
|
||||
Permission::create(['name' => $permission]);
|
||||
}
|
||||
|
||||
$userPermCheck = Permission::where('name', $userPermission)->get()->all();
|
||||
$userPermCheck = Permission::where('name', $userPermission)->get()->all();
|
||||
|
||||
if (empty($userPermCheck))
|
||||
{
|
||||
Permission::create(['name' => $userPermission]);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (empty($userPermCheck)) {
|
||||
Permission::create(['name' => $userPermission]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$admin->givePermissionTo($teamPermissions);
|
||||
$reviewer->givePermissionTo($teamUserPermissions);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -20,7 +20,6 @@
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Profile;
|
||||
use App\User;
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
@@ -34,7 +33,6 @@ class UserSeeder extends Seeder
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
|
||||
$ghostAccount = User::create([
|
||||
'uuid' => 'b741345057274a519144881927be0290', // Ghost
|
||||
'name' => 'Ghost (deleted account)',
|
||||
@@ -43,7 +41,7 @@ class UserSeeder extends Seeder
|
||||
'username' => 'ghost',
|
||||
'registrationIp' => '0.0.0.0',
|
||||
'currentIp' => '0.0.0.0',
|
||||
'password' => 'locked'
|
||||
'password' => 'locked',
|
||||
])->assignRole('user'); // There can't be role-less users
|
||||
|
||||
$admin = User::create(([
|
||||
@@ -54,7 +52,7 @@ class UserSeeder extends Seeder
|
||||
'username' => 'admin',
|
||||
'registrationIp' => '0.0.0.0',
|
||||
'currentIp' => '0.0.0.0',
|
||||
'password' => Hash::make('admin')
|
||||
'password' => Hash::make('admin'),
|
||||
]))->assignRole('user', 'reviewer', 'hiringManager', 'admin');
|
||||
|
||||
$users = User::factory()
|
||||
@@ -64,6 +62,5 @@ class UserSeeder extends Seeder
|
||||
foreach ($users as $user) {
|
||||
$user->assignRole('user');
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user