refactor: code style changes

Signed-off-by: miguel456 <me@nogueira.codes>
This commit is contained in:
2023-01-15 00:04:00 +00:00
parent 25155bff2e
commit 3727c84f3e
146 changed files with 1013 additions and 1341 deletions

View File

@@ -1,20 +1,19 @@
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
class CreateTranslationsTable extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('ltm_translations', function(Blueprint $table)
{
$table->collation = 'utf8mb4_bin';
class CreateTranslationsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('ltm_translations', function (Blueprint $table) {
$table->collation = 'utf8mb4_bin';
$table->bigIncrements('id');
$table->integer('status')->default(0);
$table->string('locale');
@@ -23,16 +22,15 @@ class CreateTranslationsTable extends Migration {
$table->text('value')->nullable();
$table->timestamps();
});
}
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('ltm_translations');
}
}
}

View File

@@ -66,7 +66,7 @@ class CreatePermissionTables extends Migration
->onDelete('cascade');
$table->primary(['permission_id', $columnNames['model_morph_key'], 'model_type'],
'model_has_permissions_permission_model_type_primary');
'model_has_permissions_permission_model_type_primary');
});
Schema::create($tableNames['model_has_roles'], function (Blueprint $table) use ($tableNames, $columnNames) {
@@ -82,7 +82,7 @@ class CreatePermissionTables extends Migration
->onDelete('cascade');
$table->primary(['role_id', $columnNames['model_morph_key'], 'model_type'],
'model_has_roles_role_model_type_primary');
'model_has_roles_role_model_type_primary');
});
Schema::create($tableNames['role_has_permissions'], function (Blueprint $table) use ($tableNames) {

View File

@@ -13,8 +13,7 @@ class OneoffApplicants extends Migration
*/
public function up()
{
Schema::create('oneoff_applicants', function(Blueprint $table){
Schema::create('oneoff_applicants', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('email');
@@ -24,10 +23,9 @@ class OneoffApplicants extends Migration
$table->foreign('application_id')
->references('id')
->on('applications')
->onDelete('cascade')
->onUpdate('cascade');
});
}

View File

@@ -14,10 +14,8 @@ class ChangeBansTable extends Migration
public function up()
{
Schema::table('bans', function (Blueprint $table) {
$table->dropColumn('userAgent');
$table->boolean('isPermanent')->default(false);
});
}
@@ -29,8 +27,8 @@ class ChangeBansTable extends Migration
public function down()
{
Schema::table('bans', function (Blueprint $table) {
$table->dropColumn('isPermanent');
$table->string('userAgent')->after('bannedUntil');
$table->dropColumn('isPermanent');
$table->string('userAgent')->after('bannedUntil');
});
}
}

View File

@@ -1,8 +1,6 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddLinkedAccountsTable extends Migration
{

View File

@@ -14,7 +14,6 @@ return new class extends Migration
public function up()
{
Schema::table('users', function (Blueprint $table) {
$table->string('password')->nullable()->change(); // social login requires no pw (still required upon normal reg)
$table->string('registrationIp')->nullable()->change();

View File

@@ -20,7 +20,6 @@
namespace Database\Seeders;
use Illuminate\Database\Seeder;
class DatabaseSeeder extends Seeder

View File

@@ -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');
}
}

View File

@@ -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');
}
}

View File

@@ -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.*');

View File

@@ -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);
}
}

View File

@@ -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');
}
}
}