From 4eb115d165e35ee4e5909b5ce86d3155708f87a9 Mon Sep 17 00:00:00 2001 From: Miguel Nogueira Date: Wed, 21 Oct 2020 00:29:50 +0000 Subject: [PATCH] Revert "Apply fixes from StyleCI (pull request #6)" This reverts pull request #6. > This pull request applies code style fixes from an analysis carried out by [StyleCI](https://bitbucket.styleci.io). > > For more information, click [here](https://bitbucket.styleci.io/analyses/a2Jl7D). --- app/Application.php | 28 +- app/Appointment.php | 25 +- app/Ban.php | 25 +- app/Comment.php | 23 +- app/Console/Commands/CountVotes.php | 87 +++---- app/Console/Commands/Install.php | 159 ++++++------ app/Console/Commands/SetEnv.php | 43 +--- app/Console/Kernel.php | 21 +- app/CustomFacades/IP.php | 45 ++-- app/Events/ApplicationApprovedEvent.php | 25 +- app/Events/ApplicationDeniedEvent.php | 24 +- app/Events/NewApplicationEvent.php | 22 +- app/Events/UserBannedEvent.php | 30 +-- app/Exceptions/Handler.php | 19 -- app/Facades/ContextAwareValidation.php | 30 +-- app/Facades/IP.php | 19 -- app/Facades/Options.php | 21 +- app/Facades/UUID.php | 23 +- app/Form.php | 21 +- app/Helpers/ContextAwareValidator.php | 191 +++++++------- app/Helpers/Options.php | 61 ++--- .../Controllers/ApplicationController.php | 143 ++++++----- .../Controllers/AppointmentController.php | 51 ++-- .../Auth/ConfirmPasswordController.php | 20 +- .../Auth/ForgotPasswordController.php | 19 -- app/Http/Controllers/Auth/LoginController.php | 35 +-- .../Controllers/Auth/RegisterController.php | 33 +-- .../Auth/ResetPasswordController.php | 20 +- app/Http/Controllers/Auth/TwofaController.php | 26 +- .../Auth/VerificationController.php | 20 +- app/Http/Controllers/BanController.php | 63 +++-- app/Http/Controllers/CommentController.php | 42 ++- app/Http/Controllers/ContactController.php | 55 ++-- app/Http/Controllers/Controller.php | 19 -- app/Http/Controllers/DashboardController.php | 38 +-- app/Http/Controllers/DevToolsController.php | 36 +-- app/Http/Controllers/FormController.php | 92 ++++--- app/Http/Controllers/HomeController.php | 23 +- app/Http/Controllers/OptionsController.php | 102 ++++---- app/Http/Controllers/ProfileController.php | 76 +++--- app/Http/Controllers/ResponseController.php | 21 +- .../Controllers/StaffProfileController.php | 21 +- app/Http/Controllers/UserController.php | 241 ++++++++++-------- app/Http/Controllers/VacancyController.php | 106 ++++---- app/Http/Controllers/VoteController.php | 27 +- app/Http/Kernel.php | 21 +- .../Middleware/ApplicationEligibility.php | 39 +-- app/Http/Middleware/Authenticate.php | 19 -- app/Http/Middleware/Bancheck.php | 31 +-- .../Middleware/CheckForMaintenanceMode.php | 19 -- app/Http/Middleware/EncryptCookies.php | 19 -- app/Http/Middleware/ForceLogoutMiddleware.php | 23 +- .../Middleware/RedirectIfAuthenticated.php | 19 -- app/Http/Middleware/TrimStrings.php | 19 -- app/Http/Middleware/TrustProxies.php | 21 +- app/Http/Middleware/UsernameUUID.php | 40 +-- app/Http/Middleware/VerifyCsrfToken.php | 19 -- app/Http/Requests/Add2FASecretRequest.php | 23 +- app/Http/Requests/BanUserRequest.php | 22 +- app/Http/Requests/ChangeEmailRequest.php | 21 +- app/Http/Requests/ChangePasswordRequest.php | 21 +- app/Http/Requests/DeleteUserRequest.php | 21 +- app/Http/Requests/FlushSessionsRequest.php | 21 +- app/Http/Requests/NewCommentRequest.php | 22 +- app/Http/Requests/ProfileSave.php | 22 +- app/Http/Requests/Remove2FASecretRequest.php | 21 +- app/Http/Requests/SaveNotesRequest.php | 21 +- app/Http/Requests/SearchPlayerRequest.php | 21 +- app/Http/Requests/UpdateUserRequest.php | 21 +- app/Http/Requests/VacancyEditRequest.php | 22 +- app/Http/Requests/VacancyRequest.php | 21 +- app/Http/Requests/VoteRequest.php | 21 +- app/Jobs/CleanBans.php | 47 ++-- app/Listeners/DenyUser.php | 24 +- app/Listeners/LogAuthenticationFailure.php | 26 +- app/Listeners/LogAuthenticationSuccess.php | 21 +- app/Listeners/OnUserBanned.php | 39 +-- app/Listeners/OnUserRegistration.php | 36 +-- app/Listeners/PromoteUser.php | 31 +-- app/Mail/NewContactSubmission.php | 20 +- app/Notifications/ApplicationApproved.php | 29 +-- app/Notifications/ApplicationDenied.php | 36 +-- app/Notifications/ApplicationMoved.php | 25 +- app/Notifications/AppointmentFinished.php | 21 +- app/Notifications/AppointmentScheduled.php | 31 +-- app/Notifications/ChangedPassword.php | 21 +- app/Notifications/EmailChanged.php | 21 +- app/Notifications/NewApplicant.php | 48 ++-- app/Notifications/NewComment.php | 30 +-- app/Notifications/NewContact.php | 35 +-- app/Notifications/NewUser.php | 58 ++--- app/Notifications/UserBanned.php | 29 +-- app/Notifications/VacancyClosed.php | 32 +-- app/Observers/ApplicationObserver.php | 33 +-- app/Observers/UserObserver.php | 30 +-- app/Observers/VacancyObserver.php | 20 +- app/Options.php | 21 +- app/Policies/ApplicationPolicy.php | 43 +--- app/Policies/AppointmentPolicy.php | 19 -- app/Policies/BanPolicy.php | 24 +- app/Policies/CommentPolicy.php | 22 +- app/Policies/FormPolicy.php | 22 +- app/Policies/ProfilePolicy.php | 20 +- app/Policies/UserPolicy.php | 26 +- app/Policies/VacancyPolicy.php | 20 -- app/Policies/VotePolicy.php | 19 -- app/Profile.php | 23 +- app/Providers/AppServiceProvider.php | 21 +- app/Providers/AuthServiceProvider.php | 49 ++-- app/Providers/BroadcastServiceProvider.php | 19 -- .../ContextAwareValidatorProvider.php | 30 +-- app/Providers/EventServiceProvider.php | 34 +-- app/Providers/IPInfoProvider.php | 25 +- app/Providers/MojangStatusProvider.php | 35 +-- app/Providers/OptionsProvider.php | 23 +- app/Providers/RouteServiceProvider.php | 19 -- app/Providers/UUIDConversionProvider.php | 25 +- app/Response.php | 22 +- app/StaffProfile.php | 21 +- app/Traits/AuthenticatesTwoFactor.php | 56 ++-- app/Traits/Cancellable.php | 32 +-- app/UUID/UUID.php | 61 ++--- app/User.php | 34 +-- app/Vacancy.php | 58 ++--- app/View/Components/Alert.php | 20 +- app/View/Components/Card.php | 23 +- app/View/Components/Form.php | 24 +- app/View/Components/GlobalErrors.php | 19 -- app/View/Components/Modal.php | 22 +- app/View/Components/NoPermission.php | 24 +- app/Vote.php | 21 +- bootstrap/app.php | 26 +- config/adminlte.php | 151 +++++------ config/app.php | 24 +- config/auth.php | 19 -- config/broadcasting.php | 19 -- config/cache.php | 19 -- config/cors.php | 19 -- config/database.php | 19 -- config/filesystems.php | 19 -- config/general.php | 34 +-- config/google2fa.php | 21 +- config/hashing.php | 19 -- config/laravellocalization.php | 21 +- config/log-viewer.php | 21 +- config/logging.php | 19 -- config/mail.php | 19 -- config/markdown.php | 18 +- config/notification.php | 27 +- config/permission.php | 19 -- config/queue.php | 19 -- config/recaptcha.php | 25 +- config/sentry.php | 19 -- config/services.php | 19 -- config/session.php | 19 -- config/slack.php | 26 +- config/view.php | 19 -- database/factories/UserFactory.php | 19 +- .../2014_10_12_000000_create_users_table.php | 19 -- ...12_100000_create_password_resets_table.php | 19 -- ..._08_19_000000_create_failed_jobs_table.php | 19 -- ...020_04_29_022245_create_profiles_table.php | 21 +- ...04_29_022402_create_applications_table.php | 21 +- .../2020_04_29_022421_create_votes_table.php | 21 +- ...04_29_022442_create_appointments_table.php | 25 +- .../2020_04_29_022541_create_forms_table.php | 21 +- ...20_04_29_022542_create_vacancies_table.php | 20 +- ..._29_023647_create_staff_profiles_table.php | 19 -- ...20_04_29_030107_create_responses_table.php | 20 +- ...020_04_29_195848_votes_has_application.php | 23 +- .../2020_05_02_223355_create_cache_table.php | 19 -- ...0_05_07_021604_add_status_to_vacancies.php | 21 +- .../2020_05_08_024654_add_slug_to_vacancy.php | 19 -- ...08_063141_add_vacancy_i_d_to_responses.php | 19 -- ...14_004542_change_form_structure_length.php | 23 +- ..._05_29_234431_create_permission_tables.php | 23 +- .../2020_06_08_153602_create_bans_table.php | 20 +- ...020_06_20_210255_create_comments_table.php | 21 +- .../2020_06_25_093708_create_jobs_table.php | 19 -- ...43_add_detailed_description_to_vacancy.php | 19 -- ...07_17_053247_add_twofa_secret_to_users.php | 19 -- ...2020_08_30_152900_create_options_table.php | 19 -- database/seeds/DatabaseSeeder.php | 19 -- database/seeds/DefaultOptionsSeeder.php | 21 +- database/seeds/NewPermissions.php | 23 +- database/seeds/PermissionSeeder.php | 34 +-- database/seeds/UserSeeder.php | 69 ++--- public/index.php | 20 +- resources/lang/en/auth.php | 19 -- resources/lang/en/messages.php | 69 ++--- resources/lang/en/pagination.php | 19 -- resources/lang/en/passwords.php | 19 -- resources/lang/en/validation.php | 19 -- resources/lang/es/auth.php | 19 -- resources/lang/es/messages.php | 69 ++--- resources/lang/es/pagination.php | 19 -- resources/lang/es/passwords.php | 19 -- resources/lang/es/validation.php | 19 -- resources/lang/fr/auth.php | 19 -- resources/lang/fr/messages.php | 69 ++--- resources/lang/fr/pagination.php | 19 -- resources/lang/fr/passwords.php | 19 -- resources/lang/fr/validation.php | 19 -- resources/lang/pt/auth.php | 19 -- resources/lang/pt/messages.php | 77 +++--- resources/lang/pt/pagination.php | 19 -- resources/lang/pt/passwords.php | 21 +- resources/lang/pt/validation.php | 19 -- routes/api.php | 19 -- routes/channels.php | 19 -- routes/console.php | 19 -- routes/web.php | 79 +++--- server.php | 20 +- tests/CreatesApplication.php | 19 -- tests/Feature/ExampleTest.php | 20 +- tests/Feature/OptionsTest.php | 21 +- tests/TestCase.php | 19 -- tests/Unit/ExampleTest.php | 19 -- 218 files changed, 1676 insertions(+), 5141 deletions(-) diff --git a/app/Application.php b/app/Application.php index eae5c83..f1066d8 100644 --- a/app/Application.php +++ b/app/Application.php @@ -1,24 +1,5 @@ . - */ - namespace App; use Illuminate\Database\Eloquent\Model; @@ -29,10 +10,13 @@ class Application extends Model 'applicantUserID', 'applicantFormResponseID', - 'applicationStatus', + 'applicationStatus' ]; + + + public function user() { return $this->belongsTo('App\User', 'applicantUserID', 'id'); @@ -53,6 +37,7 @@ class Application extends Model return $this->belongsToMany('App\Vote', 'votes_has_application'); } + public function comments() { return $this->hasMany('App\Comment', 'applicationID', 'id'); @@ -61,7 +46,8 @@ class Application extends Model public function setStatus($status) { return $this->update([ - 'applicationStatus' => $status, + 'applicationStatus' => $status ]); + } } diff --git a/app/Appointment.php b/app/Appointment.php index a87c02f..d62e39a 100644 --- a/app/Appointment.php +++ b/app/Appointment.php @@ -1,24 +1,5 @@ . - */ - namespace App; use Illuminate\Database\Eloquent\Model; @@ -32,19 +13,19 @@ class Appointment extends Model 'appointmentStatus', 'appointmentLocation', 'meetingNotes', - 'userAccepted', + 'userAccepted' ]; public function application() { - // FIXME: Possible bug here, where laravel looks for the wrong column in the applications table. + // FIXME: Possible bug here, where laravel looks for the wrong column in the applications table. return $this->belongsTo('App\Application', 'id', 'applicationID'); } public function setStatus($status) { $this->update([ - 'appointmentStatus' => $status, + 'appointmentStatus' => $status ]); } } diff --git a/app/Ban.php b/app/Ban.php index e08b336..c1a6e90 100644 --- a/app/Ban.php +++ b/app/Ban.php @@ -1,46 +1,29 @@ . - */ - namespace App; use Illuminate\Database\Eloquent\Model; class Ban extends Model { + public $fillable = [ 'userID', 'reason', 'bannedUntil', 'userAgent', - 'authorUserID', + 'authorUserID' ]; public $dates = [ - 'bannedUntil', + 'bannedUntil' ]; public function user() { return $this->belongsTo('App\User', 'userID', 'id'); } + } diff --git a/app/Comment.php b/app/Comment.php index ea4092b..c8dc8cc 100644 --- a/app/Comment.php +++ b/app/Comment.php @@ -1,34 +1,16 @@ . - */ - namespace App; use Illuminate\Database\Eloquent\Model; class Comment extends Model { + protected $fillable = [ 'authorID', 'applicationID', - 'text', + 'text' ]; public function application() @@ -40,4 +22,5 @@ class Comment extends Model { return $this->belongsTo('App\User', 'authorID', 'id'); } + } diff --git a/app/Console/Commands/CountVotes.php b/app/Console/Commands/CountVotes.php index c15ce68..a2a7c6d 100644 --- a/app/Console/Commands/CountVotes.php +++ b/app/Console/Commands/CountVotes.php @@ -1,24 +1,5 @@ . - */ - namespace App\Console\Commands; use App\Application; @@ -62,23 +43,28 @@ class CountVotes extends Command $eligibleApps = Application::where('applicationStatus', 'STAGE_PEERAPPROVAL')->get(); $pbar = $this->output->createProgressBar($eligibleApps->count()); - if ($eligibleApps->isEmpty()) { + if($eligibleApps->isEmpty()) + { $this->error('𐄂 There are no applications that need to be processed.'); return false; } - foreach ($eligibleApps as $application) { + foreach ($eligibleApps as $application) + { $votes = $application->votes; $voteCount = $application->votes->count(); $positiveVotes = 0; $negativeVotes = 0; - if ($voteCount > 5) { - $this->info('Counting votes for application ID '.$application->id); - foreach ($votes as $vote) { - switch ($vote->allowedVoteType) { + if ($voteCount > 5) + { + $this->info('Counting votes for application ID ' . $application->id); + foreach ($votes as $vote) + { + switch ($vote->allowedVoteType) + { case 'VOTE_APPROVE': $positiveVotes++; break; @@ -88,7 +74,7 @@ class CountVotes extends Command } } - $this->info('Total votes for application ID '.$application->id.': '.$voteCount); + $this->info('Total votes for application ID ' . $application->id . ': ' . $voteCount); $this->info('Calculating criteria...'); $negativeVotePercent = floor(($negativeVotes / $voteCount) * 100); $positiveVotePercent = floor(($positiveVotes / $voteCount) * 100); @@ -97,43 +83,54 @@ class CountVotes extends Command $this->table([ '% of approval votes', - '% of denial votes', + '% of denial votes' ], [ // array of arrays, e.g. rows [ - $positiveVotePercent.'%', - $negativeVotePercent.'%', - ], + $positiveVotePercent . "%", + $negativeVotePercent . "%" + ] ]); - if ($pollResult) { - $this->info('✓ Dispatched promotion event for applicant '.$application->user->name); - if (! $this->option('dryrun')) { + if ($pollResult) + { + $this->info('✓ Dispatched promotion event for applicant ' . $application->user->name); + if (!$this->option('dryrun')) + { $application->response->vacancy->vacancyCount -= 1; $application->response->vacancy->save(); event(new ApplicationApprovedEvent(Application::find($application->id))); - } else { + } + else + { $this->warn('Dry run: Event won\'t be dispatched'); } $pbar->advance(); - } else { - if (! $this->option('dryrun')) { - event(new ApplicationDeniedEvent(Application::find($application->id))); - } else { - $this->warn('Dry run: Event won\'t be dispatched'); - } - $pbar->advance(); - $this->error('𐄂 Applicant '.$application->user->name.' does not meet vote criteria (Majority)'); } - } else { - $this->warn('Application ID'.$application->id.' did not have enough votes for processing (min 5)'); + else { + + if (!$this->option('dryrun')) + { + event(new ApplicationDeniedEvent(Application::find($application->id))); + } + else { + $this->warn('Dry run: Event won\'t be dispatched'); + } + + $pbar->advance(); + $this->error('𐄂 Applicant ' . $application->user->name . ' does not meet vote criteria (Majority)'); + } } + else + { + $this->warn("Application ID" . $application->id . " did not have enough votes for processing (min 5)"); + } + } $pbar->finish(); - return true; } } diff --git a/app/Console/Commands/Install.php b/app/Console/Commands/Install.php index 18fb9a6..d7f81ae 100644 --- a/app/Console/Commands/Install.php +++ b/app/Console/Commands/Install.php @@ -1,24 +1,5 @@ . - */ - namespace App\Console\Commands; use Illuminate\Console\Command; @@ -58,89 +39,103 @@ class Install extends Command public function handle() { $basePath = base_path(); - if (Storage::disk('local')->missing('INSTALLED')) { - $this->info('[!! Welcome to Rasberry Teams !!]'); - $this->info('>> Installing...'); - $this->call('down', [ - '--message' => 'Down for maintenance. We\'ll be right back!', - ]); + if (Storage::disk('local')->missing('INSTALLED')) + { - copy($basePath.'/.env.example', $basePath.'/.env'); - $this->call('key:generate'); - $this->info('>> Installing and preparing dependencies. This may take a while, depending on your computer.'); + $this->info('[!! Welcome to Rasberry Teams !!]'); + $this->info('>> Installing...'); + $this->call('down', [ + '--message' => 'Down for maintenance. We\'ll be right back!' + ]); - $npmOut = 0; - $npmMessages = []; + copy($basePath . '/.env.example', $basePath . '/.env'); + $this->call('key:generate'); - $npmBuildOut = 0; - $npmBuildMessages = []; + $this->info('>> Installing and preparing dependencies. This may take a while, depending on your computer.'); - exec('cd '.$basePath.' && npm install --silent', $npmBuildOut, $npmOut); - exec('cd '.$basePath.'&& npm run dev --silent', $npmBuildMessages, $npmBuildOut); + $npmOut = 0; + $npmMessages = []; - if ($npmOut !== 0 && $npmBuildOut !== 0) { - $this->error('[!] One or more errors have ocurred whilst attempting to install dependencies.'); - $this->error('[!] It is recommended to run this command again, and report a bug if it keeps happening.'); + $npmBuildOut = 0; + $npmBuildMessages = []; - return false; - } + exec('cd ' . $basePath . ' && npm install --silent', $npmBuildOut, $npmOut); + exec('cd ' . $basePath . '&& npm run dev --silent', $npmBuildMessages, $npmBuildOut); - $settings = []; - $this->info('>> Configuring application - We\'re going to ask a few questions here!'); - do { - $this->info('== Database Settings (1/6) =='); + if($npmOut !== 0 && $npmBuildOut !== 0) + { + $this->error('[!] One or more errors have ocurred whilst attempting to install dependencies.'); + $this->error('[!] It is recommended to run this command again, and report a bug if it keeps happening.'); - $settings['DB_USERNAME'] = $this->ask('Database username'); - $settings['DB_PASSWORD'] = $this->secret('Database password (Input won\'t be seen)'); - $settings['DB_DATABASE'] = $this->ask('Database name'); - $settings['DB_PORT'] = $this->ask('Database port'); - $settings['DB_HOST'] = $this->ask('Database hostname'); + return false; + } - $this->info('== Antispam Settings (2/6) (Recaptcha v2) =='); - $settings['RECAPTCHA_SITE_KEY'] = $this->ask('Site key'); - $settings['RECAPTCHA_PRIVATE_KEY'] = $this->ask('Private site key'); - $this->info('== IP Geolocation Settings (3/6) (refer to README.md) =='); - $settings['IPGEO_API_KEY'] = $this->ask('API Key'); - $this->info('== Notification Settings (4/6) (Email) =='); - $settings['MAIL_USERNAME'] = $this->ask('SMTP Username'); - $settings['MAIL_PASSWORD'] = $this->secret('SMTP Password (Input won\'t be seen)'); - $settings['MAIL_PORT'] = $this->ask('SMTP Server Port'); - $settings['MAIL_HOST'] = $this->ask('SMTP Server Hostname'); - $settings['MAIL_FROM'] = $this->ask('E-mail address to send from: '); + $settings = []; - $this->info('== Notification Settings (5/6) (Slack) =='); - $settings['SLACK_INTEGRATION_WEBHOOK'] = $this->ask('Integration webhook URL'); + $this->info('>> Configuring application - We\'re going to ask a few questions here!'); + do + { + $this->info('== Database Settings (1/6) =='); - $this->info('== Web Settings (6/6) =='); - $settings['APP_URL'] = $this->ask('Application\'s URL (ex. https://where.you.installed.theapp.com): '); - $settings['APP_LOGO'] = $this->ask('App logo (Link to an image): '); - $settings['APP_SITEHOMEPAGE'] = $this->ask('Site homepage (appears in the main header): '); - } while (! $this->confirm('Are you sure you want to save these settings? You can always go back and try again.')); + $settings['DB_USERNAME'] = $this->ask('Database username'); + $settings['DB_PASSWORD'] = $this->secret('Database password (Input won\'t be seen)'); + $settings['DB_DATABASE'] = $this->ask('Database name'); + $settings['DB_PORT'] = $this->ask('Database port'); + $settings['DB_HOST'] = $this->ask('Database hostname'); - foreach ($settings as $keyname => $value) { - $this->call('environment:modify', [ - 'key' => $keyname, - 'value' => $value, - ]); - } + $this->info('== Antispam Settings (2/6) (Recaptcha v2) =='); + $settings['RECAPTCHA_SITE_KEY'] = $this->ask('Site key'); + $settings['RECAPTCHA_PRIVATE_KEY'] = $this->ask('Private site key'); - $this->info('>> Saved configuration settings!'); - $this->info('>> Preparing database...'); + $this->info('== IP Geolocation Settings (3/6) (refer to README.md) =='); + $settings['IPGEO_API_KEY'] = $this->ask('API Key'); - $this->callSilent('config:cache'); - $this->call('migrate'); - $this->call('db:seed'); + $this->info('== Notification Settings (4/6) (Email) =='); + $settings['MAIL_USERNAME'] = $this->ask('SMTP Username'); + $settings['MAIL_PASSWORD'] = $this->secret('SMTP Password (Input won\'t be seen)'); + $settings['MAIL_PORT'] = $this->ask('SMTP Server Port'); + $settings['MAIL_HOST'] = $this->ask('SMTP Server Hostname'); + $settings['MAIL_FROM'] = $this->ask('E-mail address to send from: '); - touch($basePath.'/INSTALLED'); + $this->info('== Notification Settings (5/6) (Slack) =='); + $settings['SLACK_INTEGRATION_WEBHOOK'] = $this->ask('Integration webhook URL'); - $this->call('up'); - $this->info('>> All done! Visit '.$basePath.' to start using your brand new installation of Raspberry Teams!'); - } else { - $this->error('[!] The application is already installed!'); + $this->info('== Web Settings (6/6) =='); + $settings['APP_URL'] = $this->ask('Application\'s URL (ex. https://where.you.installed.theapp.com): '); + $settings['APP_LOGO'] = $this->ask('App logo (Link to an image): '); + $settings['APP_SITEHOMEPAGE'] = $this->ask('Site homepage (appears in the main header): '); + + + } while(!$this->confirm('Are you sure you want to save these settings? You can always go back and try again.')); + + foreach($settings as $keyname => $value) + { + $this->call('environment:modify', [ + 'key' => $keyname, + 'value' => $value + ]); + } + + $this->info('>> Saved configuration settings!'); + $this->info('>> Preparing database...'); + + $this->callSilent('config:cache'); + $this->call('migrate'); + $this->call('db:seed'); + + touch($basePath . '/INSTALLED'); + + $this->call('up'); + $this->info('>> All done! Visit ' . $basePath . ' to start using your brand new installation of Raspberry Teams!'); + + } + else + { + $this->error('[!] The application is already installed!'); } } } diff --git a/app/Console/Commands/SetEnv.php b/app/Console/Commands/SetEnv.php index 3c49403..9125ffa 100644 --- a/app/Console/Commands/SetEnv.php +++ b/app/Console/Commands/SetEnv.php @@ -1,28 +1,9 @@ . - */ - namespace App\Console\Commands; -use GeoSot\EnvEditor\Facades\EnvEditor; use Illuminate\Console\Command; +use GeoSot\EnvEditor\Facades\EnvEditor; class SetEnv extends Command { @@ -56,16 +37,20 @@ class SetEnv extends Command */ public function handle() { - $path = base_path('/.env'); - $key = $this->argument('key'); - $value = $this->argument('value'); + $path = base_path('/.env'); + $key = $this->argument('key'); + $value = $this->argument('value'); - if (file_exists($path)) { - EnvEditor::editKey($key, $value); - } else { - $this->error('Cannot update a file that doesn\'t exist! Please create .env first.'); - return false; - } + + if (file_exists($path)) + { + EnvEditor::editKey($key, $value); + } + else + { + $this->error('Cannot update a file that doesn\'t exist! Please create .env first.'); + return false; + } } } diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index 28273ca..fdf4d00 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -1,29 +1,10 @@ . - */ - namespace App\Console; -use App\Jobs\CleanBans; use Illuminate\Console\Scheduling\Schedule; use Illuminate\Foundation\Console\Kernel as ConsoleKernel; +use App\Jobs\CleanBans; class Kernel extends ConsoleKernel { diff --git a/app/CustomFacades/IP.php b/app/CustomFacades/IP.php index 230ec83..2b04064 100644 --- a/app/CustomFacades/IP.php +++ b/app/CustomFacades/IP.php @@ -1,24 +1,5 @@ . - */ - namespace App\CustomFacades; use Illuminate\Support\Facades\Cache; @@ -26,6 +7,7 @@ use Illuminate\Support\Facades\Http; class IP { + /** * Looks up information on a specified IP address. Caches results automatically. * @param string $IP IP address to lookup @@ -33,18 +15,23 @@ class IP */ public function lookup(string $IP): object { - $params = [ + + $params = [ + 'apiKey' => config('general.keys.ipapi.apikey'), + 'ip' => $IP + ]; + + // TODO: Maybe unwrap this? Methods are chained here + + return json_decode(Cache::remember($IP, 3600, function() use ($IP) + { + return Http::get(config('general.urls.ipapi.ipcheck'), [ 'apiKey' => config('general.keys.ipapi.apikey'), - 'ip' => $IP, - ]; + 'ip' => $IP + ])->body(); + })); - // TODO: Maybe unwrap this? Methods are chained here - return json_decode(Cache::remember($IP, 3600, function () use ($IP) { - return Http::get(config('general.urls.ipapi.ipcheck'), [ - 'apiKey' => config('general.keys.ipapi.apikey'), - 'ip' => $IP, - ])->body(); - })); } + } diff --git a/app/Events/ApplicationApprovedEvent.php b/app/Events/ApplicationApprovedEvent.php index 066d83c..4bb005c 100644 --- a/app/Events/ApplicationApprovedEvent.php +++ b/app/Events/ApplicationApprovedEvent.php @@ -1,28 +1,13 @@ . - */ - namespace App\Events; use App\Application; +use Illuminate\Broadcasting\Channel; use Illuminate\Broadcasting\InteractsWithSockets; +use Illuminate\Broadcasting\PresenceChannel; +use Illuminate\Broadcasting\PrivateChannel; +use Illuminate\Contracts\Broadcasting\ShouldBroadcast; use Illuminate\Foundation\Events\Dispatchable; use Illuminate\Queue\SerializesModels; @@ -41,4 +26,6 @@ class ApplicationApprovedEvent { $this->application = $application; } + + } diff --git a/app/Events/ApplicationDeniedEvent.php b/app/Events/ApplicationDeniedEvent.php index 48951a3..fb84a57 100644 --- a/app/Events/ApplicationDeniedEvent.php +++ b/app/Events/ApplicationDeniedEvent.php @@ -1,28 +1,13 @@ . - */ - namespace App\Events; use App\Application; +use Illuminate\Broadcasting\Channel; use Illuminate\Broadcasting\InteractsWithSockets; +use Illuminate\Broadcasting\PresenceChannel; +use Illuminate\Broadcasting\PrivateChannel; +use Illuminate\Contracts\Broadcasting\ShouldBroadcast; use Illuminate\Foundation\Events\Dispatchable; use Illuminate\Queue\SerializesModels; @@ -41,4 +26,5 @@ class ApplicationDeniedEvent { $this->application = $application; } + } diff --git a/app/Events/NewApplicationEvent.php b/app/Events/NewApplicationEvent.php index 867ab50..bb67787 100644 --- a/app/Events/NewApplicationEvent.php +++ b/app/Events/NewApplicationEvent.php @@ -1,28 +1,12 @@ . - */ - namespace App\Events; +use Illuminate\Broadcasting\Channel; use Illuminate\Broadcasting\InteractsWithSockets; +use Illuminate\Broadcasting\PresenceChannel; use Illuminate\Broadcasting\PrivateChannel; +use Illuminate\Contracts\Broadcasting\ShouldBroadcast; use Illuminate\Foundation\Events\Dispatchable; use Illuminate\Queue\SerializesModels; diff --git a/app/Events/UserBannedEvent.php b/app/Events/UserBannedEvent.php index 05902ad..92addbf 100644 --- a/app/Events/UserBannedEvent.php +++ b/app/Events/UserBannedEvent.php @@ -1,36 +1,23 @@ . - */ - namespace App\Events; -use App\Ban; -use App\User; +use Illuminate\Broadcasting\Channel; use Illuminate\Broadcasting\InteractsWithSockets; +use Illuminate\Broadcasting\PresenceChannel; +use Illuminate\Broadcasting\PrivateChannel; +use Illuminate\Contracts\Broadcasting\ShouldBroadcast; use Illuminate\Foundation\Events\Dispatchable; use Illuminate\Queue\SerializesModels; +use App\User; +use App\Ban; + class UserBannedEvent { use Dispatchable, InteractsWithSockets, SerializesModels; + public $user; public $ban; @@ -45,4 +32,5 @@ class UserBannedEvent $this->user = $user; $this->ban = $ban; } + } diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php index 37c0edb..ff35bfd 100644 --- a/app/Exceptions/Handler.php +++ b/app/Exceptions/Handler.php @@ -1,24 +1,5 @@ . - */ - namespace App\Exceptions; use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler; diff --git a/app/Facades/ContextAwareValidation.php b/app/Facades/ContextAwareValidation.php index 41a6de8..2771c77 100644 --- a/app/Facades/ContextAwareValidation.php +++ b/app/Facades/ContextAwareValidation.php @@ -1,32 +1,14 @@ . - */ - namespace App\Facades; use Illuminate\Support\Facades\Facade; class ContextAwareValidation extends Facade { - protected static function getFacadeAccessor() - { - return 'contextAwareValidator'; - } + + protected static function getFacadeAccessor() + { + return 'contextAwareValidator'; + } + } diff --git a/app/Facades/IP.php b/app/Facades/IP.php index 0e438fb..b7301b8 100644 --- a/app/Facades/IP.php +++ b/app/Facades/IP.php @@ -1,24 +1,5 @@ . - */ - namespace App\Facades; use Illuminate\Support\Facades\Facade; diff --git a/app/Facades/Options.php b/app/Facades/Options.php index 71e9bfa..6fbd4c0 100644 --- a/app/Facades/Options.php +++ b/app/Facades/Options.php @@ -1,27 +1,8 @@ . - */ namespace App\Facades; - -use Illuminate\Support\Facades\Facade; +use \Illuminate\Support\Facades\Facade; class Options extends Facade { diff --git a/app/Facades/UUID.php b/app/Facades/UUID.php index b26e3a3..18699ee 100644 --- a/app/Facades/UUID.php +++ b/app/Facades/UUID.php @@ -1,32 +1,13 @@ . - */ - namespace App\Facades; use Illuminate\Support\Facades\Facade; -class UUID extends Facade +class UUID extends Facade { protected static function getFacadeAccessor() { return 'uuidConversionFacade'; } -} +} \ No newline at end of file diff --git a/app/Form.php b/app/Form.php index 80220fc..dc64af2 100644 --- a/app/Form.php +++ b/app/Form.php @@ -1,24 +1,5 @@ . - */ - namespace App; use Illuminate\Database\Eloquent\Model; @@ -29,7 +10,7 @@ class Form extends Model 'formName', 'formStructure', - 'formStatus', + 'formStatus' ]; diff --git a/app/Helpers/ContextAwareValidator.php b/app/Helpers/ContextAwareValidator.php index 6f59cb5..f2ffb55 100644 --- a/app/Helpers/ContextAwareValidator.php +++ b/app/Helpers/ContextAwareValidator.php @@ -1,141 +1,138 @@ . - */ - namespace App\Helpers; -use Illuminate\Support\Collection; use Illuminate\Support\Facades\Validator; +use Illuminate\Support\Collection; class ContextAwareValidator { - /** - * The excludedNames array will make the validator ignore any of these names when including names into the rules. - * @var array - */ - private $excludedNames = [ - '_token', - '_method', - 'formName', - ]; /** - * Utility wrapper for json_encode. - * - * @param array $value The array to be converted. - * @return string The JSON representation of $value - */ - private function encode(array $value): string + * The excludedNames array will make the validator ignore any of these names when including names into the rules. + * @var array + */ + private $excludedNames = [ + '_token', + '_method', + 'formName' + ]; + + + /** + * Utility wrapper for json_encode. + * + * @param array $value The array to be converted. + * @return string The JSON representation of $value + */ + private function encode(array $value) : string { - return json_encode($value); + return json_encode($value); } /** - * The getValidator() method will take an array of fields from the request body, iterates through them, - * and dynamically adds validation rules for them. Depending on parameters, it may or may not generate - * a form structure for rendering purposes. - * - * This method is mostly meant by internal use by means of static proxies (Facades), in order to reduce code repetition; - * Using it outside it's directed scope may cause unexpected results; For instance, the method expects inputs to be in array format, e.g. myFieldNameID1[], - * myFieldNameID2[], and so on and so forth. - * - * This isn't checked by the code yet, but if you're implementing it this way in the HTML markup, make sure it's consistent (e.g. use a loop). - * - * P.S This method automatically ignores the CSRF token for validation. - * - * @param array $fields The request form fields - * @param bool $generateStructure Whether to incldue a JSON-ready form structure for rendering - * @param bool $includeFormName Whether to include formName in the list of validation rules - * @return Validator|Collection A validator instance you can use to check for validity, or a Collection with a validator and structure (validator, structure) - */ + * The getValidator() method will take an array of fields from the request body, iterates through them, + * and dynamically adds validation rules for them. Depending on parameters, it may or may not generate + * a form structure for rendering purposes. + * + * This method is mostly meant by internal use by means of static proxies (Facades), in order to reduce code repetition; + * Using it outside it's directed scope may cause unexpected results; For instance, the method expects inputs to be in array format, e.g. myFieldNameID1[], + * myFieldNameID2[], and so on and so forth. + * + * This isn't checked by the code yet, but if you're implementing it this way in the HTML markup, make sure it's consistent (e.g. use a loop). + * + * P.S This method automatically ignores the CSRF token for validation. + * + * @param array $fields The request form fields + * @param bool $generateStructure Whether to incldue a JSON-ready form structure for rendering + * @param bool $includeFormName Whether to include formName in the list of validation rules + * @return Validator|Collection A validator instance you can use to check for validity, or a Collection with a validator and structure (validator, structure) + */ public function getValidator(array $fields, bool $generateStructure = false, bool $includeFormName = false) { $formStructure = []; $validator = []; - if ($includeFormName) { + if ($includeFormName) + { $validator['formName'] = 'required|string|max:100'; - } + } - foreach ($fields as $fieldName => $field) { - if (! in_array($fieldName, $this->excludedNames)) { - $validator[$fieldName.'.0'] = 'required|string'; - $validator[$fieldName.'.1'] = 'required|string'; + foreach ($fields as $fieldName => $field) + { + if(!in_array($fieldName, $this->excludedNames)) + { + $validator[$fieldName . ".0"] = 'required|string'; + $validator[$fieldName . ".1"] = 'required|string'; - if ($generateStructure) { + if ($generateStructure) + { $formStructure['fields'][$fieldName]['title'] = $field[0]; $formStructure['fields'][$fieldName]['type'] = $field[1]; - } - } - } + } - $validatorInstance = Validator::make($fields, $validator); + } + } - return ($generateStructure) ? + $validatorInstance = Validator::make($fields, $validator); + + return ($generateStructure) ? collect([ - 'validator' => $validatorInstance, - 'structure' => $this->encode($formStructure), + 'validator' => $validatorInstance, + 'structure' => $this->encode($formStructure) ]) : $validatorInstance; + + } /** - * The getResponseValidator method is similar to the getValidator method; It basically takes - * an array of fields from a previous form (that probably went through the other method) and adds validation - * to the field names. - * - * Also generates the storable response structure if you tell it to. - * - * @param array $fields The received fields - * @param array $formStructure The form structure - You must supply this if you want the response structure - * @param bool $generateResponseStructure Whether to generate the response structure - * @return Validator|Collection A collection or a validator, depending on the args. Will return validatior if only fields are supplied. - */ + * The getResponseValidator method is similar to the getValidator method; It basically takes + * an array of fields from a previous form (that probably went through the other method) and adds validation + * to the field names. + * + * Also generates the storable response structure if you tell it to. + * + * @param array $fields The received fields + * @param array $formStructure The form structure - You must supply this if you want the response structure + * @param bool $generateResponseStructure Whether to generate the response structure + * @return Validator|Collection A collection or a validator, depending on the args. Will return validatior if only fields are supplied. + */ public function getResponseValidator(array $fields, array $formStructure = [], bool $generateResponseStructure = true) { - $responseStructure = []; - $validator = []; - if (empty($formStructure) && $generateResponseStructure) { - throw new \InvalidArgumentException('Illegal combination of arguments supplied! Please check the method\'s documentation.'); - } + $responseStructure = []; + $validator = []; - foreach ($fields as $fieldName => $value) { - if (! in_array($fieldName, $this->excludedNames)) { - $validator[$fieldName] = 'required|string'; + if (empty($formStructure) && $generateResponseStructure) + { + throw new \InvalidArgumentException('Illegal combination of arguments supplied! Please check the method\'s documentation.'); + } - if ($generateResponseStructure) { - $responseStructure['responses'][$fieldName]['type'] = $formStructure['fields'][$fieldName]['type'] ?? 'Unavailable'; - $responseStructure['responses'][$fieldName]['title'] = $formStructure['fields'][$fieldName]['title']; - $responseStructure['responses'][$fieldName]['response'] = $value; - } - } - } + foreach($fields as $fieldName => $value) + { + if(!in_array($fieldName, $this->excludedNames)) + { + $validator[$fieldName] = 'required|string'; - $validatorInstance = Validator::make($fields, $validator); + if ($generateResponseStructure) + { + $responseStructure['responses'][$fieldName]['type'] = $formStructure['fields'][$fieldName]['type'] ?? 'Unavailable'; + $responseStructure['responses'][$fieldName]['title'] = $formStructure['fields'][$fieldName]['title']; + $responseStructure['responses'][$fieldName]['response'] = $value; + } + } + } - return ($generateResponseStructure) ? + $validatorInstance = Validator::make($fields, $validator); + + return ($generateResponseStructure) ? collect([ - 'validator' => $validatorInstance, - 'responseStructure' => $this->encode($responseStructure), + 'validator' => $validatorInstance, + 'responseStructure' => $this->encode($responseStructure) ]) : $validatorInstance; + } + } diff --git a/app/Helpers/Options.php b/app/Helpers/Options.php index 925d910..13c416d 100644 --- a/app/Helpers/Options.php +++ b/app/Helpers/Options.php @@ -1,23 +1,5 @@ . - */ namespace App\Helpers; @@ -27,18 +9,20 @@ use Illuminate\Support\Facades\Log; class Options { + public function getOption(string $option): string { $value = Cache::get($option); - if (is_null($value)) { - Log::debug('Option '.$option.'not found in cache, refreshing from database'); + if (is_null($value)) + { + Log::debug('Option ' . $option . 'not found in cache, refreshing from database'); $value = Option::where('option_name', $option)->first(); - if (is_null($value)) { + if (is_null($value)) throw new \Exception('This option does not exist.'); - } + Cache::put($option, $value); - Cache::put($option.'_desc', 'Undefined description'); + Cache::put($option . '_desc', 'Undefined description'); } return $value->option_value; @@ -46,14 +30,14 @@ class Options public function setOption(string $option, string $value, string $description) { - Option::create([ - 'option_name' => $option, - 'option_value' => $value, - 'friendly_name' => $description, - ]); + Option::create([ + 'option_name' => $option, + 'option_value' => $value, + 'friendly_name' => $description + ]); - Cache::put($option, $value, now()->addDay()); - Cache::put($option.'_desc', $description, now()->addDay()); + Cache::put($option, $value, now()->addDay()); + Cache::put($option . '_desc', $description, now()->addDay()); } public function pullOption($option): array @@ -64,7 +48,7 @@ class Options // putMany is overkill here return [ Cache::pull($option), - Cache::pull($option.'_desc'), + Cache::pull($option . '_desc') ]; } @@ -72,13 +56,14 @@ class Options { $dbOption = Option::where('option_name', $option); - if ($dbOption->first()) { + if ($dbOption->first()) + { $dbOptionInstance = Option::find($dbOption->first()->id); Cache::forget($option); Log::debug('Changing db configuration option', [ 'old_value' => $dbOptionInstance->option_value, - 'new_value' => $newValue, + 'new_value' => $newValue ]); $dbOptionInstance->option_value = $newValue; @@ -86,20 +71,24 @@ class Options Log::debug('New db configuration option saved', [ - 'option' => $dbOptionInstance->option_value, + 'option' => $dbOptionInstance->option_value ]); Cache::put('option_name', $newValue, now()->addDay()); - } else { + } + else + { throw new \Exception('This option does not exist.'); } } + public function optionExists(string $option): bool { $dbOption = Option::where('option_name', $option)->first(); $locallyCachedOption = Cache::get($option); - return ! is_null($dbOption) || ! is_null($locallyCachedOption); + return !is_null($dbOption) || !is_null($locallyCachedOption); } + } diff --git a/app/Http/Controllers/ApplicationController.php b/app/Http/Controllers/ApplicationController.php index 2102759..bcedc0a 100644 --- a/app/Http/Controllers/ApplicationController.php +++ b/app/Http/Controllers/ApplicationController.php @@ -1,46 +1,36 @@ . - */ - namespace App\Http\Controllers; use App\Application; -use App\Events\ApplicationDeniedEvent; -use App\Notifications\ApplicationMoved; -use App\Notifications\NewApplicant; + use App\Response; -use App\User; use App\Vacancy; -use ContextAwareValidator; +use App\User; + +use App\Events\ApplicationDeniedEvent; +use App\Notifications\NewApplicant; +use App\Notifications\ApplicationMoved; + use Illuminate\Http\Request; use Illuminate\Support\Facades\Auth; +use Illuminate\Support\Facades\Validator; +use Illuminate\Support\Facades\App; use Illuminate\Support\Facades\Log; +use ContextAwareValidator; + class ApplicationController extends Controller { + private function canVote($votes) { $allvotes = collect([]); - foreach ($votes as $vote) { - if ($vote->userID == Auth::user()->id) { + foreach ($votes as $vote) + { + if ($vote->userID == Auth::user()->id) + { $allvotes->push($vote); } } @@ -48,17 +38,22 @@ class ApplicationController extends Controller return ($allvotes->count() == 1) ? false : true; } + + public function showUserApps() { + return view('dashboard.user.applications') ->with('applications', Auth::user()->applications); } + public function showUserApp(Request $request, Application $application) { $this->authorize('view', $application); - if (! is_null($application)) { + if (!is_null($application)) + { return view('dashboard.user.viewapp') ->with( [ @@ -67,16 +62,20 @@ class ApplicationController extends Controller 'structuredResponses' => json_decode($application->response->responseData, true), 'formStructure' => $application->response->form, 'vacancy' => $application->response->vacancy, - 'canVote' => $this->canVote($application->votes), + 'canVote' => $this->canVote($application->votes) ] ); - } else { + } + else + { $request->session()->flash('error', 'The application you requested could not be found.'); } return redirect()->back(); } + + public function showAllApps() { $this->authorize('viewAny', Application::class); @@ -85,6 +84,7 @@ class ApplicationController extends Controller ->with('applications', Application::paginate(6)); } + public function showAllPendingApps() { $this->authorize('viewAny', Application::class); @@ -93,6 +93,7 @@ class ApplicationController extends Controller ->with('applications', Application::where('applicationStatus', 'STAGE_SUBMITTED')->get()); } + public function showPendingInterview() { $this->authorize('viewAny', Application::class); @@ -102,12 +103,16 @@ class ApplicationController extends Controller $pendingInterviews = collect([]); $upcomingInterviews = collect([]); - foreach ($applications as $application) { - if (! is_null($application->appointment) && $application->appointment->appointmentStatus == 'CONCLUDED') { - $count = +1; + + foreach ($applications as $application) + { + if (!is_null($application->appointment) && $application->appointment->appointmentStatus == 'CONCLUDED') + { + $count =+ 1; } - switch ($application->applicationStatus) { + switch ($application->applicationStatus) + { case 'STAGE_INTERVIEW': $upcomingInterviews->push($application); @@ -118,24 +123,29 @@ class ApplicationController extends Controller break; } + } return view('dashboard.appmanagement.interview') ->with([ 'finishedCount' => $count, 'applications' => $pendingInterviews, - 'upcomingApplications' => $upcomingInterviews, + 'upcomingApplications' => $upcomingInterviews ]); } + + public function showPeerReview() { $this->authorize('viewAny', Application::class); - return view('dashboard.appmanagement.peerreview') ->with('applications', Application::where('applicationStatus', 'STAGE_PEERAPPROVAL')->get()); + } + + public function renderApplicationForm(Request $request, $vacancySlug) { // FIXME: Get rid of references to first(), this is a wonky query @@ -143,27 +153,36 @@ class ApplicationController extends Controller $firstVacancy = $vacancyWithForm->first(); - if (! $vacancyWithForm->isEmpty() && $firstVacancy->vacancyCount !== 0 && $firstVacancy->vacancyStatus == 'OPEN') { + if (!$vacancyWithForm->isEmpty() && $firstVacancy->vacancyCount !== 0 && $firstVacancy->vacancyStatus == 'OPEN') + { + return view('dashboard.application-rendering.apply') ->with([ 'vacancy' => $vacancyWithForm->first(), - 'preprocessedForm' => json_decode($vacancyWithForm->first()->forms->formStructure, true), + 'preprocessedForm' => json_decode($vacancyWithForm->first()->forms->formStructure, true) ]); - } else { + } + else + { abort(404, 'The application you\'re looking for could not be found or it is currently unavailable.'); } + } + + public function saveApplicationAnswers(Request $request, $vacancySlug) { $vacancy = Vacancy::with('forms')->where('vacancySlug', $vacancySlug)->get(); - if ($vacancy->first()->vacancyCount == 0 || $vacancy->first()->vacancyStatus !== 'OPEN') { - $request->session()->flash('error', 'This application is unavailable.'); + if ($vacancy->first()->vacancyCount == 0 || $vacancy->first()->vacancyStatus !== 'OPEN') + { + + $request->session()->flash('error', 'This application is unavailable.'); + return redirect()->back(); - return redirect()->back(); } Log::info('Processing new application!'); @@ -173,14 +192,15 @@ class ApplicationController extends Controller Log::info('Built response & validator structure!'); - if (! $responseValidation->get('validator')->fails()) { + if (!$responseValidation->get('validator')->fails()) + { $response = Response::create([ 'responseFormID' => $vacancy->first()->forms->id, 'associatedVacancyID' => $vacancy->first()->id, // Since a form can be used by multiple vacancies, we can only know which specific vacancy this response ties to by using a vacancy ID - 'responseData' => $responseValidation->get('responseStructure'), + 'responseData' => $responseValidation->get('responseStructure') ]); - Log::info('Registered form response for user '.Auth::user()->name.' for vacancy '.$vacancy->first()->vacancyName); + Log::info('Registered form response for user ' . Auth::user()->name . ' for vacancy ' . $vacancy->first()->vacancyName); $application = Application::create([ 'applicantUserID' => Auth::user()->id, @@ -188,20 +208,24 @@ class ApplicationController extends Controller 'applicationStatus' => 'STAGE_SUBMITTED', ]); - Log::info('Submitted application for user '.Auth::user()->name.' with response ID'.$response->id); + Log::info('Submitted application for user ' . Auth::user()->name . ' with response ID' . $response->id); - foreach (User::all() as $user) { - if ($user->hasRole('admin')) { - $user->notify((new NewApplicant($application, $vacancy->first()))->delay(now()->addSeconds(10))); - } + foreach(User::all() as $user) + { + if ($user->hasRole('admin')) + { + $user->notify((new NewApplicant($application, $vacancy->first()))->delay(now()->addSeconds(10))); + } } $request->session()->flash('success', 'Thank you for your application! It will be reviewed as soon as possible.'); - return redirect()->to(route('showUserApps')); - } else { - Log::warning('Application form for '.Auth::user()->name.' contained errors, resetting!'); + } + else + { + Log::warning('Application form for ' . Auth::user()->name . ' contained errors, resetting!'); $request->session()->flash('error', 'There are one or more errors in your application. Please make sure none of your fields are empty, since they are all required.'); + } return redirect()->back(); @@ -211,14 +235,15 @@ class ApplicationController extends Controller { $this->authorize('update', Application::class); - switch ($newStatus) { + switch ($newStatus) + { case 'deny': event(new ApplicationDeniedEvent($application)); break; case 'interview': - Log::info('User '.Auth::user()->name.' has moved application ID '.$application->id.'to interview stage'); + Log::info('User ' . Auth::user()->name . ' has moved application ID ' . $application->id . 'to interview stage'); $request->session()->flash('success', 'Application moved to interview stage! (:'); $application->setStatus('STAGE_INTERVIEW'); @@ -234,11 +259,13 @@ class ApplicationController extends Controller public function delete(Request $request, Application $application) { - $this->authorize('delete', $application); - $application->delete(); // observers will run, cleaning it up - $request->session()->flash('success', 'Application deleted. Comments, appointments and responses have also been deleted.'); + $this->authorize('delete', $application); + $application->delete(); // observers will run, cleaning it up + + $request->session()->flash('success', 'Application deleted. Comments, appointments and responses have also been deleted.'); + return redirect()->back(); - return redirect()->back(); } + } diff --git a/app/Http/Controllers/AppointmentController.php b/app/Http/Controllers/AppointmentController.php index 3931995..8ed2722 100644 --- a/app/Http/Controllers/AppointmentController.php +++ b/app/Http/Controllers/AppointmentController.php @@ -1,33 +1,14 @@ . - */ - namespace App\Http\Controllers; use App\Application; -use App\Appointment; use App\Http\Requests\SaveNotesRequest; -use App\Notifications\ApplicationMoved; -use App\Notifications\AppointmentScheduled; use Carbon\Carbon; use Illuminate\Http\Request; +use App\Appointment; +use App\Notifications\ApplicationMoved; +use App\Notifications\AppointmentScheduled; use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Log; @@ -39,7 +20,7 @@ class AppointmentController extends Controller 'DISCORD', 'SKYPE', 'MEET', - 'TEAMSPEAK', + 'TEAMSPEAK' ]; @@ -56,24 +37,26 @@ class AppointmentController extends Controller ]); $application->setStatus('STAGE_INTERVIEW_SCHEDULED'); - Log::info('User '.Auth::user()->name.' has scheduled an appointment with '.$application->user->name.' for application ID'.$application->id, [ + + Log::info('User ' . Auth::user()->name . ' has scheduled an appointment with ' . $application->user->name . ' for application ID' . $application->id, [ 'datetime' => $appointmentDate->toDateTimeString(), - 'scheduled' => now(), + 'scheduled' => now() ]); $application->user->notify(new AppointmentScheduled($appointment)); - $request->session()->flash('success', 'Appointment successfully scheduled @ '.$appointmentDate->toDateTimeString()); + $request->session()->flash('success', 'Appointment successfully scheduled @ ' . $appointmentDate->toDateTimeString()); + return redirect()->back(); } public function updateAppointment(Request $request, Application $application, $status) { - $this->authorize('update', $application->appointment); + $this->authorize('update', $application->appointment); $validStatuses = [ - 'SCHEDULED', - 'CONCLUDED', + 'SCHEDULED', + 'CONCLUDED' ]; // NOTE: This is a little confusing, refactor @@ -83,25 +66,29 @@ class AppointmentController extends Controller $application->setStatus('STAGE_PEERAPPROVAL'); $application->user->notify(new ApplicationMoved()); - $request->session()->flash('success', 'Interview finished! Staff members can now vote on it.'); + $request->session()->flash('success', 'Interview finished! Staff members can now vote on it.'); return redirect()->back(); } // also updates public function saveNotes(SaveNotesRequest $request, Application $application) { - if (! is_null($application)) { + if (!is_null($application)) + { $application->load('appointment'); $application->appointment->meetingNotes = $request->noteText; $application->appointment->save(); $request->session()->flash('success', 'Meeting notes have been saved.'); - } else { + } + else + { $request->session()->flash('error', 'There\'s no appointment to save notes to!'); } return redirect()->back(); } + } diff --git a/app/Http/Controllers/Auth/ConfirmPasswordController.php b/app/Http/Controllers/Auth/ConfirmPasswordController.php index 10760cc..71a9592 100644 --- a/app/Http/Controllers/Auth/ConfirmPasswordController.php +++ b/app/Http/Controllers/Auth/ConfirmPasswordController.php @@ -1,27 +1,9 @@ . - */ - namespace App\Http\Controllers\Auth; use App\Http\Controllers\Controller; +use App\Providers\RouteServiceProvider; use Illuminate\Foundation\Auth\ConfirmsPasswords; class ConfirmPasswordController extends Controller diff --git a/app/Http/Controllers/Auth/ForgotPasswordController.php b/app/Http/Controllers/Auth/ForgotPasswordController.php index 2ddd570..465c39c 100644 --- a/app/Http/Controllers/Auth/ForgotPasswordController.php +++ b/app/Http/Controllers/Auth/ForgotPasswordController.php @@ -1,24 +1,5 @@ . - */ - namespace App\Http\Controllers\Auth; use App\Http\Controllers\Controller; diff --git a/app/Http/Controllers/Auth/LoginController.php b/app/Http/Controllers/Auth/LoginController.php index a762270..47413e2 100644 --- a/app/Http/Controllers/Auth/LoginController.php +++ b/app/Http/Controllers/Auth/LoginController.php @@ -1,28 +1,10 @@ . - */ - namespace App\Http\Controllers\Auth; -use App\Http\Controllers\Controller; use App\User; +use App\Http\Controllers\Controller; +use App\Providers\RouteServiceProvider; use Illuminate\Foundation\Auth\AuthenticatesUsers; use Illuminate\Http\Request; @@ -66,15 +48,22 @@ class LoginController extends Controller { $user = User::where('email', $request->email)->first(); - if ($user) { + if ($user) + { $isBanned = $user->isBanned(); - if ($isBanned) { + if ($isBanned) + { return false; - } else { + } + else + { return $this->originalAttemptLogin($request); } } return $this->originalAttemptLogin($request); + } + + } diff --git a/app/Http/Controllers/Auth/RegisterController.php b/app/Http/Controllers/Auth/RegisterController.php index 2b9d69f..c6b3364 100644 --- a/app/Http/Controllers/Auth/RegisterController.php +++ b/app/Http/Controllers/Auth/RegisterController.php @@ -1,32 +1,15 @@ . - */ - namespace App\Http\Controllers\Auth; use App\Http\Controllers\Controller; use App\Profile; +use App\Providers\RouteServiceProvider; use App\User; use Illuminate\Foundation\Auth\RegistersUsers; use Illuminate\Support\Facades\Hash; use Illuminate\Support\Facades\Validator; +use function GuzzleHttp\Psr7\str; class RegisterController extends Controller { @@ -64,8 +47,10 @@ class RegisterController extends Controller { $users = User::where('originalIP', \request()->ip())->get(); - foreach ($users as $user) { - if ($user && $user->isBanned()) { + foreach($users as $user) + { + if ($user && $user->isBanned()) + { abort(403, 'You do not have permission to access this page.'); } } @@ -87,7 +72,7 @@ class RegisterController extends Controller 'email' => ['required', 'string', 'email', 'max:255', 'unique:users'], 'password' => ['required', 'string', 'min:10', 'confirmed', 'regex:/^.*(?=.{3,})(?=.*[a-zA-Z])(?=.*[0-9])(?=.*[\d\x])(?=.*[!$#%]).*$/'], ], [ - 'uuid.required' => 'Please enter a valid (and Premium) Minecraft username! We do not support cracked users.', + 'uuid.required' => 'Please enter a valid (and Premium) Minecraft username! We do not support cracked users.' ]); } @@ -99,19 +84,19 @@ class RegisterController extends Controller */ protected function create(array $data) { + $user = User::create([ 'uuid' => $data['uuid'], 'name' => $data['name'], 'email' => $data['email'], 'password' => Hash::make($data['password']), - 'originalIP' => request()->ip(), + 'originalIP' => request()->ip() ]); // It's not the registration controller's concern to create a profile for the user, // so this code has been moved to it's respective observer, following the separation of concerns pattern. $user->assignRole('user'); - return $user; } } diff --git a/app/Http/Controllers/Auth/ResetPasswordController.php b/app/Http/Controllers/Auth/ResetPasswordController.php index bbf75a7..6c0c13a 100644 --- a/app/Http/Controllers/Auth/ResetPasswordController.php +++ b/app/Http/Controllers/Auth/ResetPasswordController.php @@ -1,27 +1,9 @@ . - */ - namespace App\Http\Controllers\Auth; use App\Http\Controllers\Controller; +use App\Providers\RouteServiceProvider; use Illuminate\Foundation\Auth\ResetsPasswords; class ResetPasswordController extends Controller diff --git a/app/Http/Controllers/Auth/TwofaController.php b/app/Http/Controllers/Auth/TwofaController.php index d8bad0e..a3ecac9 100644 --- a/app/Http/Controllers/Auth/TwofaController.php +++ b/app/Http/Controllers/Auth/TwofaController.php @@ -1,32 +1,16 @@ . - */ - namespace App\Http\Controllers\Auth; +use Illuminate\Http\Request; use App\Http\Controllers\Controller; use App\Traits\AuthenticatesTwoFactor; class TwofaController extends Controller { - use AuthenticatesTwoFactor; + use AuthenticatesTwoFactor; + + + protected $redirectTo = '/dashboard'; - protected $redirectTo = '/dashboard'; } diff --git a/app/Http/Controllers/Auth/VerificationController.php b/app/Http/Controllers/Auth/VerificationController.php index 74be54b..482a167 100644 --- a/app/Http/Controllers/Auth/VerificationController.php +++ b/app/Http/Controllers/Auth/VerificationController.php @@ -1,27 +1,9 @@ . - */ - namespace App\Http\Controllers\Auth; use App\Http\Controllers\Controller; +use App\Providers\RouteServiceProvider; use Illuminate\Foundation\Auth\VerifiesEmails; class VerificationController extends Controller diff --git a/app/Http/Controllers/BanController.php b/app/Http/Controllers/BanController.php index f472910..3ae2a42 100644 --- a/app/Http/Controllers/BanController.php +++ b/app/Http/Controllers/BanController.php @@ -1,48 +1,35 @@ . - */ - namespace App\Http\Controllers; -use App\Ban; -use App\Events\UserBannedEvent; -use App\Http\Requests\BanUserRequest; -use App\User; use Illuminate\Http\Request; use Illuminate\Support\Facades\Auth; +use App\Ban; +use App\User; +use App\Events\UserBannedEvent; +use App\Http\Requests\BanUserRequest; class BanController extends Controller { + public function insert(BanUserRequest $request, User $user) { + $this->authorize('create', [Ban::class, $user]); - if (is_null($user->bans)) { + if (is_null($user->bans)) + { + $reason = $request->reason; $duration = strtolower($request->durationOperator); $durationOperand = $request->durationOperand; $expiryDate = now(); - if (! empty($duration)) { - switch ($duration) { + if (!empty($duration)) + { + switch($duration) + { case 'days': $expiryDate->addDays($durationOperand); break; @@ -59,7 +46,9 @@ class BanController extends Controller $expiryDate->addYears($durationOperand); break; } - } else { + } + else + { // Essentially permanent $expiryDate->addYears(5); } @@ -68,27 +57,35 @@ class BanController extends Controller 'userID' => $user->id, 'reason' => $reason, 'bannedUntil' => $expiryDate->format('Y-m-d H:i:s'), - 'userAgent' => 'Unknown', - 'authorUserID' => Auth::user()->id, + 'userAgent' => "Unknown", + 'authorUserID' => Auth::user()->id ]); event(new UserBannedEvent($user, $ban)); - $request->session()->flash('success', 'User banned successfully! Ban ID: #'.$ban->id); - } else { + $request->session()->flash('success', 'User banned successfully! Ban ID: #' . $ban->id); + + } + else + { $request->session()->flash('error', 'User already banned!'); } return redirect()->back(); } + public function delete(Request $request, User $user) { + $this->authorize('delete', $user->bans); - if (! is_null($user->bans)) { + if (!is_null($user->bans)) + { $user->bans->delete(); $request->session()->flash('success', 'User unbanned successfully!'); - } else { + } + else + { $request->session()->flash('error', 'This user isn\'t banned!'); } diff --git a/app/Http/Controllers/CommentController.php b/app/Http/Controllers/CommentController.php index 3f7fc11..09d2aa2 100644 --- a/app/Http/Controllers/CommentController.php +++ b/app/Http/Controllers/CommentController.php @@ -1,34 +1,19 @@ . - */ - namespace App\Http\Controllers; -use App\Application; -use App\Comment; -use App\Http\Requests\NewCommentRequest; use Illuminate\Http\Request; use Illuminate\Support\Facades\Auth; +use App\Http\Requests\NewCommentRequest; + +use App\Comment; +use App\Application; +use App\Notifications\NewComment; +use App\User; class CommentController extends Controller { + public function index() { // @@ -41,16 +26,21 @@ class CommentController extends Controller $comment = Comment::create([ 'authorID' => Auth::user()->id, 'applicationID' => $application->id, - 'text' => $request->comment, + 'text' => $request->comment ]); - if ($comment) { + if ($comment) + { + $request->session()->flash('success', 'Comment posted! (:'); - } else { + } + else + { $request->session()->flash('error', 'Something went wrong while posting your comment!'); } return redirect()->back(); + } public function delete(Request $request, Comment $comment) @@ -61,5 +51,7 @@ class CommentController extends Controller $request->session()->flash('success', 'Comment deleted!'); return redirect()->back(); + } + } diff --git a/app/Http/Controllers/ContactController.php b/app/Http/Controllers/ContactController.php index c2cb2ef..7a2923f 100644 --- a/app/Http/Controllers/ContactController.php +++ b/app/Http/Controllers/ContactController.php @@ -1,40 +1,26 @@ . - */ - namespace App\Http\Controllers; -use App\Notifications\NewContact; -use App\User; use Illuminate\Http\Request; +use GuzzleHttp; +use App\Notifications\NewContact; use Illuminate\Support\Facades\Http; +use App\User; + class ContactController extends Controller { + protected $users; + public function __construct(User $users) { $this->users = $users; } + public function create(Request $request) { $name = $request->name; @@ -48,29 +34,32 @@ class ContactController extends Controller $verifyrequest = Http::asForm()->post(config('recaptcha.verify.apiurl'), [ 'secret' => config('recaptcha.keys.secret'), 'response' => $challenge, - 'remoteip' => $request->ip(), + 'remoteip' => $request->ip() ]); + $response = json_decode($verifyrequest->getBody(), true); - if (! $response['success']) { + if (!$response['success']) + { $request->session()->flash('error', 'Beep beep boop... Robot? Submission failed.'); - return redirect()->back(); } - foreach (User::all() as $user) { - if ($user->hasRole('admin')) { - $user->notify(new NewContact(collect([ - 'message' => $msg, - 'ip' => $request->ip(), - 'email' => $email, - ]))); - } + + foreach(User::all() as $user) + { + if ($user->hasRole('admin')) + { + $user->notify(new NewContact(collect([ + 'message' => $msg, + 'ip' => $request->ip(), + 'email' => $email + ]))); + } } $request->session()->flash('success', 'Message sent successfully! We usually respond within 48 hours.'); - return redirect()->back(); } } diff --git a/app/Http/Controllers/Controller.php b/app/Http/Controllers/Controller.php index 5f92f69..a0a2a8a 100644 --- a/app/Http/Controllers/Controller.php +++ b/app/Http/Controllers/Controller.php @@ -1,24 +1,5 @@ . - */ - namespace App\Http\Controllers; use Illuminate\Foundation\Auth\Access\AuthorizesRequests; diff --git a/app/Http/Controllers/DashboardController.php b/app/Http/Controllers/DashboardController.php index 573ae61..d397d89 100644 --- a/app/Http/Controllers/DashboardController.php +++ b/app/Http/Controllers/DashboardController.php @@ -1,32 +1,16 @@ . - */ - namespace App\Http\Controllers; -use App\Application; -use App\User; +use Illuminate\Http\Request; use App\Vacancy; +use App\User; +use App\Ban; +use App\Application; class DashboardController extends Controller { + public function index() { $totalPeerReview = Application::where('applicationStatus', 'STAGE_PEERAPPROVAL')->get()->count(); @@ -35,11 +19,13 @@ class DashboardController extends Controller return view('dashboard.dashboard') ->with([ - 'vacancies' => Vacancy::all(), - 'totalUserCount' => User::all()->count(), - 'totalDenied' => $totalDenied, - 'totalPeerReview' => $totalPeerReview, - 'totalNewApplications' => $totalNewApplications, + 'vacancies' => Vacancy::all(), + 'totalUserCount' => User::all()->count(), + 'totalDenied' => $totalDenied, + 'totalPeerReview' => $totalPeerReview, + 'totalNewApplications' => $totalNewApplications ]); + } + } diff --git a/app/Http/Controllers/DevToolsController.php b/app/Http/Controllers/DevToolsController.php index 1749ed5..5c82d26 100644 --- a/app/Http/Controllers/DevToolsController.php +++ b/app/Http/Controllers/DevToolsController.php @@ -1,45 +1,28 @@ . - */ - namespace App\Http\Controllers; use App\Application; use App\Events\ApplicationApprovedEvent; use Illuminate\Http\Request; + use Illuminate\Support\Facades\Auth; class DevToolsController extends Controller { + // The use case for Laravel's gate and/or validation Requests is so tiny here that a full-blown policy would be overkill. protected function isolatedAuthorise() { - if (! Auth::user()->can('admin.developertools.use')) { - abort(403, 'You\'re not authorized to access this page.'); - } + if (!Auth::user()->can('admin.developertools.use')) + { + abort(403, 'You\'re not authorized to access this page.'); + } } public function index() { $this->isolatedAuthorise(); - return view('dashboard.administration.devtools') ->with('applications', Application::where('applicationStatus', 'STAGE_PEERAPPROVAL')->get()); } @@ -49,11 +32,14 @@ class DevToolsController extends Controller $this->isolatedAuthorise(); $application = Application::find($request->application); - if (! is_null($application)) { + if (!is_null($application)) + { event(new ApplicationApprovedEvent($application)); $request->session()->flash('success', 'Event dispatched! Please check the debug logs for more info'); - } else { + } + else + { $request->session()->flash('error', 'Application doesn\'t exist!'); } diff --git a/app/Http/Controllers/FormController.php b/app/Http/Controllers/FormController.php index dbd09f6..27d40dd 100644 --- a/app/Http/Controllers/FormController.php +++ b/app/Http/Controllers/FormController.php @@ -1,32 +1,17 @@ . - */ - namespace App\Http\Controllers; use App\Form; -use ContextAwareValidator; use Illuminate\Http\Request; +use Illuminate\Support\Facades\Validator; +use Illuminate\Support\Facades\Auth; + +use ContextAwareValidator; class FormController extends Controller { + public function index() { $forms = Form::all(); @@ -39,35 +24,34 @@ class FormController extends Controller public function showFormBuilder() { $this->authorize('viewFormbuilder', Form::class); - return view('dashboard.administration.formbuilder'); } public function saveForm(Request $request) { + $this->authorize('create', Form::class); $fields = $request->all(); $contextValidation = ContextAwareValidator::getValidator($fields, true, true); - if (! $contextValidation->get('validator')->fails()) { + if (!$contextValidation->get('validator')->fails()) + { $storableFormStructure = $contextValidation->get('structure'); Form::create( [ 'formName' => $fields['formName'], 'formStructure' => $storableFormStructure, - 'formStatus' => 'ACTIVE', + 'formStatus' => 'ACTIVE' ] ); $request->session()->flash('success', 'Form created! You can now link this form to a vacancy.'); - return redirect()->to(route('showForms')); } $request->session()->flash('errors', $contextValidation->get('validator')->errors()->getMessages()); - return redirect()->back(); } @@ -76,19 +60,25 @@ class FormController extends Controller $this->authorize('delete', $form); $deletable = true; - if (! is_null($form) && ! is_null($form->vacancies) && $form->vacancies->count() !== 0 || ! is_null($form->responses)) { - $deletable = false; + + if (!is_null($form) && !is_null($form->vacancies) && $form->vacancies->count() !== 0 || !is_null($form->responses)) + { + $deletable = false; } - if ($deletable) { - $form->delete(); + if ($deletable) + { + $form->delete(); - $request->session()->flash('success', 'Form deleted successfully.'); - } else { - $request->session()->flash('error', 'You cannot delete this form because it\'s tied to one or more applications and ranks, or because it doesn\'t exist.'); + $request->session()->flash('success', 'Form deleted successfully.'); + } + else + { + $request->session()->flash('error', 'You cannot delete this form because it\'s tied to one or more applications and ranks, or because it doesn\'t exist.'); } return redirect()->back(); + } public function preview(Request $request, Form $form) @@ -103,9 +93,9 @@ class FormController extends Controller public function edit(Request $request, Form $form) { - $this->authorize('update', $form); + $this->authorize('update', $form); - return view('dashboard.administration.editform') + return view('dashboard.administration.editform') ->with('formStructure', json_decode($form->formStructure, true)) ->with('title', $form->formName) ->with('formID', $form->id); @@ -113,23 +103,29 @@ class FormController extends Controller public function update(Request $request, Form $form) { - $this->authorize('update', $form); + $this->authorize('update', $form); - $contextValidation = ContextAwareValidator::getValidator($request->all(), true); - $this->authorize('update', $form); + $contextValidation = ContextAwareValidator::getValidator($request->all(), true); + $this->authorize('update', $form); - if (! $contextValidation->get('validator')->fails()) { - // Add the new structure into the form. New, subsquent fields will be identified by the "new" prefix - // This prefix doesn't actually change the app's behavior when it receives applications. - // Additionally, old applications won't of course display new and updated fields, because we can't travel into the past and get data for them - $form->formStructure = $contextValidation->get('structure'); - $form->save(); - $request->session()->flash('success', 'Hooray! Your form was updated. New applications for it\'s vacancy will use it.'); - } else { - $request->session()->flash('errors', $contextValidation->get('validator')->errors()->getMessages()); - } + if (!$contextValidation->get('validator')->fails()) + { + // Add the new structure into the form. New, subsquent fields will be identified by the "new" prefix + // This prefix doesn't actually change the app's behavior when it receives applications. + // Additionally, old applications won't of course display new and updated fields, because we can't travel into the past and get data for them + $form->formStructure = $contextValidation->get('structure'); + $form->save(); + + $request->session()->flash('success', 'Hooray! Your form was updated. New applications for it\'s vacancy will use it.'); + } + else + { + $request->session()->flash('errors', $contextValidation->get('validator')->errors()->getMessages()); + } + + return redirect()->to(route('previewForm', ['form' => $form->id])); - return redirect()->to(route('previewForm', ['form' => $form->id])); } + } diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php index 2696b59..1afc222 100644 --- a/app/Http/Controllers/HomeController.php +++ b/app/Http/Controllers/HomeController.php @@ -1,27 +1,10 @@ . - */ - namespace App\Http\Controllers; use App\Vacancy; +use Illuminate\Http\Request; +use Illuminate\Support\Facades\DB; class HomeController extends Controller { @@ -32,10 +15,12 @@ class HomeController extends Controller */ public function index() { + $positions = Vacancy::where('vacancyStatus', 'OPEN') ->where('vacancyCount', '<>', 0) ->get(); + return view('home') ->with('positions', $positions); } diff --git a/app/Http/Controllers/OptionsController.php b/app/Http/Controllers/OptionsController.php index 2bba992..c76a57c 100644 --- a/app/Http/Controllers/OptionsController.php +++ b/app/Http/Controllers/OptionsController.php @@ -1,28 +1,10 @@ . - */ - namespace App\Http\Controllers; use App\Facades\Options; use App\Options as Option; + use Illuminate\Http\Request; use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Log; @@ -39,47 +21,57 @@ class OptionsController extends Controller // TODO: Obtain this from the facade $options = Option::all(); + return view('dashboard.administration.settings') ->with('options', $options); } - public function saveSettings(Request $request) - { - if (Auth::user()->can('admin.settings.edit')) { - Log::debug('Updating application options', [ - 'ip' => $request->ip(), - 'ua' => $request->userAgent(), - 'username' => Auth::user()->username, - ]); - foreach ($request->all() as $optionName => $option) { - try { - Log::debug('Going through option '.$optionName); - if (Options::optionExists($optionName)) { - Log::debug('Option exists, updating to new values', [ - 'opt' => $optionName, - 'new_value' => $option, - ]); - Options::changeOption($optionName, $option); - } - } catch (\Exception $ex) { - Log::error('Unable to update options!', [ - 'msg' => $ex->getMessage(), - 'trace' => $ex->getTraceAsString(), - ]); - report($ex); + public function saveSettings(Request $request) + { + if (Auth::user()->can('admin.settings.edit')) + { + Log::debug('Updating application options', [ + 'ip' => $request->ip(), + 'ua' => $request->userAgent(), + 'username' => Auth::user()->username + ]); + foreach($request->all() as $optionName => $option) + { + try + { + Log::debug('Going through option ' . $optionName); + if (Options::optionExists($optionName)) + { + Log::debug('Option exists, updating to new values', [ + 'opt' => $optionName, + 'new_value' => $option + ]); + Options::changeOption($optionName, $option); + } + } + catch(\Exception $ex) + { + Log::error('Unable to update options!', [ + 'msg' => $ex->getMessage(), + 'trace' => $ex->getTraceAsString() + ]); + report($ex); - $errorCond = true; - $request->session()->flash('error', 'An error occurred while trying to save settings: '.$ex->getMessage()); - } - } + $errorCond = true; + $request->session()->flash('error', 'An error occurred while trying to save settings: ' . $ex->getMessage()); + } + } - if (! isset($errorCond)) { - $request->session()->flash('success', 'Settings saved successfully!'); - } - } else { - $request->session()->flash('error', 'You do not have permission to update this resource.'); - } + if (!isset($errorCond)) + { + $request->session()->flash('success', 'Settings saved successfully!'); + } + } + else + { + $request->session()->flash('error', 'You do not have permission to update this resource.'); + } - return redirect()->back(); - } + return redirect()->back(); + } } diff --git a/app/Http/Controllers/ProfileController.php b/app/Http/Controllers/ProfileController.php index 0f63b2d..0fc063d 100644 --- a/app/Http/Controllers/ProfileController.php +++ b/app/Http/Controllers/ProfileController.php @@ -1,29 +1,12 @@ . - */ - namespace App\Http\Controllers; -use App\Facades\IP; use App\Http\Requests\ProfileSave; +use Illuminate\Support\Facades\Log; +use App\Profile; use App\User; +use App\Facades\IP; use Carbon\Carbon; use Illuminate\Http\Request; use Illuminate\Support\Facades\Auth; @@ -31,15 +14,18 @@ use Spatie\Permission\Models\Role; class ProfileController extends Controller { - public function index() - { - return view('dashboard.user.directory') + + public function index() + { + + return view('dashboard.user.directory') ->with('users', User::with('profile', 'bans')->paginate(9)); - } + } public function showProfile() { - $socialLinks = Auth::user()->profile->socialLinks ?? '[]'; + + $socialLinks = Auth::user()->profile->socialLinks ?? "[]"; $socialMediaProfiles = json_decode($socialLinks, true); return view('dashboard.user.profile.userprofile') @@ -50,11 +36,13 @@ class ProfileController extends Controller 'insta' => $socialMediaProfiles['links']['insta'] ?? 'UpdateMe', 'discord' => $socialMediaProfiles['links']['discord'] ?? 'UpdateMe#12345', ]); + } // Route model binding public function showSingleProfile(Request $request, User $user) { + $socialMediaProfiles = json_decode($user->profile->socialLinks, true); $createdDate = Carbon::parse($user->created_at); @@ -63,15 +51,21 @@ class ProfileController extends Controller $roleList = []; - foreach ($systemRoles as $role) { - if (in_array($role, $userRoles)) { - $roleList[$role] = true; - } else { - $roleList[$role] = false; - } + + foreach($systemRoles as $role) + { + if (in_array($role, $userRoles)) + { + $roleList[$role] = true; + } + else + { + $roleList[$role] = false; + } } - if (Auth::user()->is($user) || Auth::user()->can('profiles.view.others')) { + if (Auth::user()->is($user) || Auth::user()->can('profiles.view.others')) + { return view('dashboard.user.profile.displayprofile') ->with([ 'profile' => $user->profile, @@ -79,13 +73,16 @@ class ProfileController extends Controller 'twitter' => $socialMediaProfiles['links']['twitter'] ?? 'UpdateMe', 'insta' => $socialMediaProfiles['links']['insta'] ?? 'UpdateMe', 'discord' => $socialMediaProfiles['links']['discord'] ?? 'UpdateMe#12345', - 'since' => $createdDate->englishMonth.' '.$createdDate->year, + 'since' => $createdDate->englishMonth . " " . $createdDate->year, 'ipInfo' => IP::lookup($user->originalIP), - 'roles' => $roleList, + 'roles' => $roleList ]); - } else { + } + else + { abort(403, 'You cannot view someone else\'s profile.'); } + } public function saveProfile(ProfileSave $request) @@ -93,8 +90,10 @@ class ProfileController extends Controller $profile = User::find(Auth::user()->id)->profile; $social = []; - if (! is_null($profile)) { - switch ($request->avatarPref) { + if (!is_null($profile)) + { + switch ($request->avatarPref) + { case 'MOJANG': $avatarPref = 'crafatar'; @@ -118,8 +117,11 @@ class ProfileController extends Controller $newProfile = $profile->save(); $request->session()->flash('success', 'Profile settings saved successfully.'); + } return redirect()->back(); + } + } diff --git a/app/Http/Controllers/ResponseController.php b/app/Http/Controllers/ResponseController.php index bcb5070..64037c9 100644 --- a/app/Http/Controllers/ResponseController.php +++ b/app/Http/Controllers/ResponseController.php @@ -1,26 +1,9 @@ . - */ - namespace App\Http\Controllers; +use Illuminate\Http\Request; + class ResponseController extends Controller { // diff --git a/app/Http/Controllers/StaffProfileController.php b/app/Http/Controllers/StaffProfileController.php index 1f6b569..b20d4d1 100644 --- a/app/Http/Controllers/StaffProfileController.php +++ b/app/Http/Controllers/StaffProfileController.php @@ -1,26 +1,9 @@ . - */ - namespace App\Http\Controllers; +use Illuminate\Http\Request; + class StaffProfileController extends Controller { // diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php index 3ee74ff..cb494b6 100644 --- a/app/Http/Controllers/UserController.php +++ b/app/Http/Controllers/UserController.php @@ -1,47 +1,34 @@ . - */ - namespace App\Http\Controllers; -use App\Ban; -use App\Http\Requests\Add2FASecretRequest; use App\Http\Requests\ChangeEmailRequest; use App\Http\Requests\ChangePasswordRequest; -use App\Http\Requests\DeleteUserRequest; use App\Http\Requests\FlushSessionsRequest; -use App\Http\Requests\Remove2FASecretRequest; +use App\Http\Requests\DeleteUserRequest; use App\Http\Requests\SearchPlayerRequest; use App\Http\Requests\UpdateUserRequest; -use App\Notifications\ChangedPassword; -use App\Notifications\EmailChanged; +use App\Http\Requests\Add2FASecretRequest; +use App\Http\Requests\Remove2FASecretRequest; + use App\User; -use Google2FA; +use App\Ban; + use Illuminate\Http\Request; use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Hash; use Illuminate\Support\Facades\Log; +use App\Facades\UUID; +use App\Notifications\EmailChanged; +use App\Notifications\ChangedPassword; use Spatie\Permission\Models\Role; +use Google2FA; + class UserController extends Controller { + + public function showStaffMembers() { $this->authorize('viewStaff', User::class); @@ -49,20 +36,24 @@ class UserController extends Controller $staffRoles = [ 'reviewer', 'hiringManager', - 'admin', + 'admin' ]; // TODO: Un-hardcode this, move to config/roles.php $users = User::with('roles')->get(); $staffMembers = collect([]); - foreach ($users as $user) { - if (empty($user->roles)) { + foreach($users as $user) + { + if (empty($user->roles)) + { Log::debug($user->role->name); Log::debug('Staff list: User without role detected; Ignoring'); continue; } - foreach ($user->roles as $role) { - if (in_array($role->name, $staffRoles)) { + foreach($user->roles as $role) + { + if (in_array($role->name, $staffRoles)) + { $staffMembers->push($user); continue 2; // Skip directly to the next user instead of comparing more roles for the current user } @@ -71,7 +62,7 @@ class UserController extends Controller return view('dashboard.administration.staff-members') ->with([ - 'users' => $staffMembers, + 'users' => $staffMembers ]); } @@ -82,9 +73,11 @@ class UserController extends Controller $users = User::with('roles')->get(); $players = collect([]); - foreach ($users as $user) { + foreach($users as $user) + { // TODO: Might be problematic if we don't check if the role is user - if (count($user->roles) == 1) { + if (count($user->roles) == 1) + { $players->push($user); } } @@ -92,10 +85,11 @@ class UserController extends Controller return view('dashboard.administration.players') ->with([ 'users' => $players, - 'bannedUserCount' => Ban::all()->count(), + 'bannedUserCount' => Ban::all()->count() ]); } + public function showPlayersLike(SearchPlayerRequest $request) { $this->authorize('viewPlayers', User::class); @@ -106,17 +100,18 @@ class UserController extends Controller ->orWhere('email', 'LIKE', "%{$searchTerm}%") ->get(); - if (! $matchingUsers->isEmpty()) { - $request->session()->flash('success', 'There were '.$matchingUsers->count().' user(s) matching your search.'); + if (!$matchingUsers->isEmpty()) + { $request->session()->flash('success', 'There were ' . $matchingUsers->count() . ' user(s) matching your search.'); return view('dashboard.administration.players') ->with([ 'users' => $matchingUsers, - 'bannedUserCount' => Ban::all()->count(), + 'bannedUserCount' => Ban::all()->count() ]); - } else { + } + else + { $request->session()->flash('error', 'Your search term did not return any results.'); - return redirect(route('registeredPlayerList')); } } @@ -125,10 +120,14 @@ class UserController extends Controller { $QRCode = null; - if (! $request->user()->has2FA()) { - if ($request->session()->has('twofaAttemptFailed')) { + if (!$request->user()->has2FA()) + { + if ($request->session()->has('twofaAttemptFailed')) + { $twoFactorSecret = $request->session()->get('current2FA'); - } else { + } + else + { $twoFactorSecret = Google2FA::generateSecretKey(32, ''); $request->session()->put('current2FA', $twoFactorSecret); } @@ -145,21 +144,21 @@ class UserController extends Controller ->with('twofaQRCode', $QRCode); } + public function flushSessions(FlushSessionsRequest $request) { // TODO: Move all log calls to a listener, which binds to an event fired by each significant event, such as this one // This will allow for other actions to be performed on certain events (like login failed event) Auth::logoutOtherDevices($request->currentPasswordFlush); - Log::notice('User '.Auth::user()->name.' has logged out other devices in their account', + Log::notice('User ' . Auth::user()->name . ' has logged out other devices in their account', [ 'originIPAddress' => $request->ip(), 'userID' => Auth::user()->id, - 'timestamp' => now(), + 'timestamp' => now() ]); $request->session()->flash('success', 'Successfully logged out other devices. Remember to change your password if you think you\'ve been compromised.'); - return redirect()->back(); } @@ -167,92 +166,111 @@ class UserController extends Controller { $user = User::find(Auth::user()->id); - if (! is_null($user)) { + if (!is_null($user)) + { $user->password = Hash::make($request->newPassword); $user->save(); - Log::info('User '.$user->name.' has changed their password', [ + Log::info('User ' . $user->name . ' has changed their password', [ 'originIPAddress' => $request->ip(), 'userID' => $user->id, - 'timestamp' => now(), + 'timestamp' => now() ]); $user->notify(new ChangedPassword()); Auth::logout(); - return redirect()->back(); } + } public function changeEmail(ChangeEmailRequest $request) { $user = User::find(Auth::user()->id); - if (! is_null($user)) { + if (!is_null($user)) + { $user->email = $request->newEmail; $user->save(); - Log::notice('User '.$user->name.' has just changed their contact email address', [ + Log::notice('User ' . $user->name . ' has just changed their contact email address', [ 'originIPAddress' => $request->ip(), 'userID' => $user->id, - 'timestamp' => now(), + 'timestamp' => now() ]); $user->notify(new EmailChanged()); $request->session()->flash('success', 'Your email address has been changed!'); - } else { + } + else + { $request->session()->flash('error', 'There has been an error whilst trying to update your account. Please contact administrators.'); } return redirect()->back(); + } + + public function delete(DeleteUserRequest $request, User $user) { + $this->authorize('delete', $user); - if ($request->confirmPrompt == 'DELETE ACCOUNT') { + if ($request->confirmPrompt == 'DELETE ACCOUNT') + { $user->delete(); - $request->session()->flash('success', 'User deleted successfully. PII has been erased.'); - } else { + $request->session()->flash('success','User deleted successfully. PII has been erased.'); + } + else + { $request->session()->flash('error', 'Wrong confirmation text! Try again.'); } + return redirect()->route('registeredPlayerList'); } public function update(UpdateUserRequest $request, User $user) { - $this->authorize('adminEdit', $user); - // Mass update would not be possible here without extra code, making route model binding useless - $user->email = $request->email; - $user->name = $request->name; - $user->uuid = $request->uuid; + $this->authorize('adminEdit', $user); - $existingRoles = Role::all() + // Mass update would not be possible here without extra code, making route model binding useless + $user->email = $request->email; + $user->name = $request->name; + $user->uuid = $request->uuid; + + $existingRoles = Role::all() ->pluck('name') ->all(); - $roleDiff = array_diff($existingRoles, $request->roles); + $roleDiff = array_diff($existingRoles, $request->roles); - // Adds roles that were selected. Removes roles that aren't selected if the user has them. - foreach ($roleDiff as $deselectedRole) { - if ($user->hasRole($deselectedRole) && $deselectedRole !== 'user') { - $user->removeRole($deselectedRole); - } + // Adds roles that were selected. Removes roles that aren't selected if the user has them. + foreach($roleDiff as $deselectedRole) + { + if ($user->hasRole($deselectedRole) && $deselectedRole !== 'user') + { + $user->removeRole($deselectedRole); + } + } + + foreach($request->roles as $role) + { + if (!$user->hasRole($role)) + { + $user->assignRole($role); } - foreach ($request->roles as $role) { - if (! $user->hasRole($role)) { - $user->assignRole($role); - } - } + } - $user->save(); - $request->session()->flash('success', 'User updated successfully!'); + $user->save(); + $request->session()->flash('success', 'User updated successfully!'); + + return redirect()->back(); - return redirect()->back(); } public function add2FASecret(Add2FASecretRequest $request) @@ -260,32 +278,35 @@ class UserController extends Controller $currentSecret = $request->session()->get('current2FA'); $isValid = Google2FA::verifyKey($currentSecret, $request->otp); - if ($isValid) { - $request->user()->twofa_secret = $currentSecret; - $request->user()->save(); + if ($isValid) + { + $request->user()->twofa_secret = $currentSecret; + $request->user()->save(); - Log::warning('SECURITY: User activated two-factor authentication', [ - 'initiator' => $request->user()->email, - 'ip' => $request->ip(), - ]); + Log::warning('SECURITY: User activated two-factor authentication', [ + 'initiator' => $request->user()->email, + 'ip' => $request->ip() + ]); - Google2FA::login(); + Google2FA::login(); - Log::warning('SECURITY: Started two factor session automatically', [ - 'initiator' => $request->user()->email, - 'ip' => $request->ip(), - ]); + Log::warning('SECURITY: Started two factor session automatically', [ + 'initiator' => $request->user()->email, + 'ip' => $request->ip() + ]); - $request->session()->forget('current2FA'); + $request->session()->forget('current2FA'); - if ($request->session()->has('twofaAttemptFailed')) { - $request->session()->forget('twofaAttemptFailed'); - } + if ($request->session()->has('twofaAttemptFailed')) + $request->session()->forget('twofaAttemptFailed'); - $request->session()->flash('success', '2FA succesfully enabled! You\'ll now be prompted for an OTP each time you log in.'); - } else { - $request->session()->flash('error', 'Incorrect code. Please reopen the 2FA settings panel and try again.'); - $request->session()->put('twofaAttemptFailed', true); + + $request->session()->flash('success', '2FA succesfully enabled! You\'ll now be prompted for an OTP each time you log in.'); + } + else + { + $request->session()->flash('error', 'Incorrect code. Please reopen the 2FA settings panel and try again.'); + $request->session()->put('twofaAttemptFailed', true); } return redirect()->back(); @@ -294,38 +315,42 @@ class UserController extends Controller public function remove2FASecret(Remove2FASecretRequest $request) { Log::warning('SECURITY: Disabling two factor authentication (user initiated)', [ - 'initiator' => $request->user()->email, - 'ip' => $request->ip(), + 'initiator' => $request->user()->email, + 'ip' => $request->ip() ]); $request->user()->twofa_secret = null; $request->user()->save(); $request->session()->flash('success', 'Two-factor authentication disabled.'); - return redirect()->back(); } + + + public function terminate(Request $request, User $user) { $this->authorize('terminate', User::class); // TODO: move logic to policy - if (! $user->isStaffMember() || $user->is(Auth::user())) { + if (!$user->isStaffMember() || $user->is(Auth::user())) + { $request->session()->flash('error', 'You cannot terminate this user.'); - return redirect()->back(); } - foreach ($user->roles as $role) { - if ($role->name == 'user') { - continue; - } + foreach ($user->roles as $role) + { + if ($role->name == 'user') + { + continue; + } - $user->removeRole($role->name); + $user->removeRole($role->name); } - Log::info('User '.$user->name.' has just been demoted.'); + Log::info('User ' . $user->name . ' has just been demoted.'); $request->session()->flash('success', 'User terminated successfully.'); //TODO: Dispatch event diff --git a/app/Http/Controllers/VacancyController.php b/app/Http/Controllers/VacancyController.php index 5316d3b..fdb5ce0 100644 --- a/app/Http/Controllers/VacancyController.php +++ b/app/Http/Controllers/VacancyController.php @@ -1,45 +1,30 @@ . - */ - namespace App\Http\Controllers; -use App\Form; -use App\Http\Requests\VacancyEditRequest; use App\Http\Requests\VacancyRequest; -use App\Notifications\VacancyClosed; -use App\User; +use App\Http\Requests\VacancyEditRequest; + use App\Vacancy; +use App\User; +use App\Form; + +use App\Notifications\VacancyClosed; + use Illuminate\Http\Request; use Illuminate\Support\Str; +use Illuminate\Support\Facades\Auth; + class VacancyController extends Controller { public function index() { - $this->authorize('viewAny', Vacancy::class); - + $this->authorize('viewAny', Vacancy::class); return view('dashboard.administration.positions') ->with([ 'forms' => Form::all(), - 'vacancies' => Vacancy::all(), + 'vacancies' => Vacancy::all() ]); } @@ -48,12 +33,13 @@ class VacancyController extends Controller $this->authorize('create', Vacancy::class); $form = Form::find($request->vacancyFormID); - if (! is_null($form)) { - /* note: since we can't convert HTML back to Markdown, we'll have to do the converting when the user requests a page, - * and leave the database with Markdown only so it can be used and edited everywhere. - * for several vacancies, this would require looping through all of them and replacing MD with HTML, which is obviously not the most clean solution; - * however, the Model can be configured to return MD instead of HTML on that specific field saving us from looping. - */ + if (!is_null($form)) + { + /* note: since we can't convert HTML back to Markdown, we'll have to do the converting when the user requests a page, + * and leave the database with Markdown only so it can be used and edited everywhere. + * for several vacancies, this would require looping through all of them and replacing MD with HTML, which is obviously not the most clean solution; + * however, the Model can be configured to return MD instead of HTML on that specific field saving us from looping. + */ Vacancy::create([ 'vacancyName' => $request->vacancyName, @@ -63,40 +49,48 @@ class VacancyController extends Controller 'permissionGroupName' => $request->permissionGroup, 'discordRoleID' => $request->discordRole, 'vacancyFormID' => $request->vacancyFormID, - 'vacancyCount' => $request->vacancyCount, + 'vacancyCount' => $request->vacancyCount ]); $request->session()->flash('success', 'Vacancy successfully opened. It will now show in the home page.'); - } else { + } + else + { $request->session()->flash('error', 'You cannot create a vacancy without a valid form.'); } return redirect()->back(); + } public function updatePositionAvailability(Request $request, $status, Vacancy $vacancy) { + $this->authorize('update', $vacancy); - if (! is_null($vacancy)) { + if (!is_null($vacancy)) + { $type = 'success'; - switch ($status) { + switch ($status) + { case 'open': $vacancy->open(); - $message = 'Position successfully opened!'; + $message = "Position successfully opened!"; break; case 'close': $vacancy->close(); - $message = 'Position successfully closed!'; + $message = "Position successfully closed!"; - foreach (User::all() as $user) { - if ($user->isStaffMember()) { - $user->notify(new VacancyClosed($vacancy)); - } + foreach(User::all() as $user) + { + if ($user->isStaffMember()) + { + $user->notify(new VacancyClosed($vacancy)); + } } break; @@ -105,36 +99,40 @@ class VacancyController extends Controller $type = 'error'; } - } else { + } + else + { $message = "The position you're trying to update doesn't exist!"; - $type = 'error'; + $type = "error"; } $request->session()->flash($type, $message); - return redirect()->back(); } + public function edit(Request $request, Vacancy $vacancy) { - $this->authorize('update', $vacancy); - + $this->authorize('update', $vacancy); return view('dashboard.administration.editposition') ->with('vacancy', $vacancy); } + + public function update(VacancyEditRequest $request, Vacancy $vacancy) { - $this->authorize('update', $vacancy); + $this->authorize('update', $vacancy); - $vacancy->vacancyFullDescription = $request->vacancyFullDescription; - $vacancy->vacancyDescription = $request->vacancyDescription; - $vacancy->vacancyCount = $request->vacancyCount; + $vacancy->vacancyFullDescription = $request->vacancyFullDescription; + $vacancy->vacancyDescription = $request->vacancyDescription; + $vacancy->vacancyCount = $request->vacancyCount; - $vacancy->save(); + $vacancy->save(); - $request->session()->flash('success', 'Vacancy successfully updated.'); + $request->session()->flash('success', 'Vacancy successfully updated.'); + return redirect()->back(); - return redirect()->back(); } + } diff --git a/app/Http/Controllers/VoteController.php b/app/Http/Controllers/VoteController.php index 30eb2ea..eba3ae1 100644 --- a/app/Http/Controllers/VoteController.php +++ b/app/Http/Controllers/VoteController.php @@ -1,34 +1,18 @@ . - */ - namespace App\Http\Controllers; use App\Application; use App\Http\Requests\VoteRequest; +use App\Jobs\ProcessVoteList; use App\Vote; +use Illuminate\Http\Request; use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Log; class VoteController extends Controller { + public function vote(VoteRequest $voteRequest, Application $application) { $this->authorize('create', Vote::class); @@ -39,8 +23,9 @@ class VoteController extends Controller ]); $vote->application()->attach($application->id); - Log::info('User '.Auth::user()->name.' has voted in applicant '.$application->user->name.'\'s application', [ - 'voteType' => $voteRequest->voteType, + + Log::info('User ' . Auth::user()->name . ' has voted in applicant ' . $application->user->name . '\'s application', [ + 'voteType' => $voteRequest->voteType ]); $voteRequest->session()->flash('success', 'Your vote has been registered!'); diff --git a/app/Http/Kernel.php b/app/Http/Kernel.php index f0d3604..9a2a7f5 100644 --- a/app/Http/Kernel.php +++ b/app/Http/Kernel.php @@ -1,24 +1,5 @@ . - */ - namespace App\Http; use Illuminate\Foundation\Http\Kernel as HttpKernel; @@ -89,6 +70,6 @@ class Kernel extends HttpKernel 'localizationRedirect' => \Mcamara\LaravelLocalization\Middleware\LaravelLocalizationRedirectFilter::class, 'localeSessionRedirect' => \Mcamara\LaravelLocalization\Middleware\LocaleSessionRedirect::class, 'localeCookieRedirect' => \Mcamara\LaravelLocalization\Middleware\LocaleCookieRedirect::class, - 'localeViewPath' => \Mcamara\LaravelLocalization\Middleware\LaravelLocalizationViewPath::class, + 'localeViewPath' => \Mcamara\LaravelLocalization\Middleware\LaravelLocalizationViewPath::class ]; } diff --git a/app/Http/Middleware/ApplicationEligibility.php b/app/Http/Middleware/ApplicationEligibility.php index 13cb1da..f091d8e 100644 --- a/app/Http/Middleware/ApplicationEligibility.php +++ b/app/Http/Middleware/ApplicationEligibility.php @@ -1,31 +1,12 @@ . - */ - namespace App\Http\Middleware; use App\Application; +use Illuminate\Support\Facades\Log; use Carbon\Carbon; use Closure; use Illuminate\Support\Facades\Auth; -use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\View; class ApplicationEligibility @@ -42,29 +23,37 @@ class ApplicationEligibility { $curtime = new Carbon(now()); - if (Auth::check()) { + + if (Auth::check()) + { $applications = Application::where('applicantUserID', Auth::user()->id)->get(); $eligible = true; $daysRemaining = 0; - if (! $applications->isEmpty()) { - foreach ($applications as $application) { + if (!$applications->isEmpty()) + { + foreach ($applications as $application) + { $appTime = Carbon::parse($application->created_at); - if ($appTime->isSameMonth($curtime)) { - Log::warning('Notice: Application ID '.$application->id.' was found to be in the same month as today\'s time, making the user '.Auth::user()->name.' ineligible for application'); + if ($appTime->isSameMonth($curtime)) + { + + Log::warning('Notice: Application ID ' . $application->id . ' was found to be in the same month as today\'s time, making the user ' . Auth::user()->name . ' ineligible for application'); $eligible = false; } } $allowedTime = Carbon::parse($applications->last()->created_at)->addMonth(); $daysRemaining = $allowedTime->diffInDays(now()); + } View::share('isEligibleForApplication', $eligible); View::share('eligibilityDaysRemaining', $daysRemaining); } + return $next($request); } } diff --git a/app/Http/Middleware/Authenticate.php b/app/Http/Middleware/Authenticate.php index af34268..704089a 100644 --- a/app/Http/Middleware/Authenticate.php +++ b/app/Http/Middleware/Authenticate.php @@ -1,24 +1,5 @@ . - */ - namespace App\Http\Middleware; use Illuminate\Auth\Middleware\Authenticate as Middleware; diff --git a/app/Http/Middleware/Bancheck.php b/app/Http/Middleware/Bancheck.php index 6c8a8ef..0eca7f7 100644 --- a/app/Http/Middleware/Bancheck.php +++ b/app/Http/Middleware/Bancheck.php @@ -1,24 +1,5 @@ . - */ - namespace App\Http\Middleware; use Closure; @@ -39,11 +20,17 @@ class Bancheck $userIP = $request->ip(); $anonymousUser = User::where('ipAddress', $userIP)->get(); - if (Auth::check() && Auth::user()->isBanned()) { + + if (Auth::check() && Auth::user()->isBanned()) + { View::share('isBanned', true); - } elseif (! $anonymousUser->isEmpty() && User::find($anonymousUser->id)->isBanned()) { + } + elseif(!$anonymousUser->isEmpty() && User::find($anonymousUser->id)->isBanned()) + { View::share('isBanned', true); - } else { + } + else + { View::share('isBanned', false); } diff --git a/app/Http/Middleware/CheckForMaintenanceMode.php b/app/Http/Middleware/CheckForMaintenanceMode.php index c58ffff..35b9824 100644 --- a/app/Http/Middleware/CheckForMaintenanceMode.php +++ b/app/Http/Middleware/CheckForMaintenanceMode.php @@ -1,24 +1,5 @@ . - */ - namespace App\Http\Middleware; use Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode as Middleware; diff --git a/app/Http/Middleware/EncryptCookies.php b/app/Http/Middleware/EncryptCookies.php index 140dd8d..033136a 100644 --- a/app/Http/Middleware/EncryptCookies.php +++ b/app/Http/Middleware/EncryptCookies.php @@ -1,24 +1,5 @@ . - */ - namespace App\Http\Middleware; use Illuminate\Cookie\Middleware\EncryptCookies as Middleware; diff --git a/app/Http/Middleware/ForceLogoutMiddleware.php b/app/Http/Middleware/ForceLogoutMiddleware.php index 7501cdd..551c287 100644 --- a/app/Http/Middleware/ForceLogoutMiddleware.php +++ b/app/Http/Middleware/ForceLogoutMiddleware.php @@ -1,24 +1,5 @@ . - */ - namespace App\Http\Middleware; use Closure; @@ -35,11 +16,11 @@ class ForceLogoutMiddleware */ public function handle($request, Closure $next) { - if (Auth::user()->isBanned()) { + if (Auth::user()->isBanned()) + { Auth::logout(); $request->session()->flash('error', 'Error: Your session has been forcefully terminated. Please try again in a few days.'); - return redirect('/'); } diff --git a/app/Http/Middleware/RedirectIfAuthenticated.php b/app/Http/Middleware/RedirectIfAuthenticated.php index 674a32b..2395ddc 100644 --- a/app/Http/Middleware/RedirectIfAuthenticated.php +++ b/app/Http/Middleware/RedirectIfAuthenticated.php @@ -1,24 +1,5 @@ . - */ - namespace App\Http\Middleware; use App\Providers\RouteServiceProvider; diff --git a/app/Http/Middleware/TrimStrings.php b/app/Http/Middleware/TrimStrings.php index 1698610..5a50e7b 100644 --- a/app/Http/Middleware/TrimStrings.php +++ b/app/Http/Middleware/TrimStrings.php @@ -1,24 +1,5 @@ . - */ - namespace App\Http\Middleware; use Illuminate\Foundation\Http\Middleware\TrimStrings as Middleware; diff --git a/app/Http/Middleware/TrustProxies.php b/app/Http/Middleware/TrustProxies.php index 785351e..085cdb5 100644 --- a/app/Http/Middleware/TrustProxies.php +++ b/app/Http/Middleware/TrustProxies.php @@ -1,24 +1,5 @@ . - */ - namespace App\Http\Middleware; use Fideloper\Proxy\TrustProxies as Middleware; @@ -31,7 +12,7 @@ class TrustProxies extends Middleware * * @var array|string */ - protected $proxies = '*'; + protected $proxies = "*"; /** * The headers that should be used to detect proxies. diff --git a/app/Http/Middleware/UsernameUUID.php b/app/Http/Middleware/UsernameUUID.php index 32c8a8e..29a93cf 100644 --- a/app/Http/Middleware/UsernameUUID.php +++ b/app/Http/Middleware/UsernameUUID.php @@ -1,33 +1,15 @@ . - */ - namespace App\Http\Middleware; -use App\Facades\UUID; use Closure; +use App\Facades\UUID; +use Illuminate\Support\Facades\Http; class UsernameUUID { /** - * Converts a Minecraft username found in the request body to a UUID. + * Converts a Minecraft username found in the request body to a UUID * * @param \Illuminate\Http\Request $request * @param \Closure $next @@ -36,21 +18,23 @@ class UsernameUUID public function handle($request, Closure $next) { $input = $request->all(); - if (isset($input['uuid'])) { - try { - $username = $input['uuid']; - $input['uuid'] = UUID::toUUID($username); - } catch (\InvalidArgumentException $iae) { + if (isset($input['uuid'])) + { + try + { + $username = $input['uuid']; + $input['uuid'] = UUID::toUUID($username); + } + catch(\InvalidArgumentException $iae) + { report($iae); $request->session()->flash('error', $iae->getMessage()); - return redirect(route('register')); } $request->replace($input); } - return $next($request); } } diff --git a/app/Http/Middleware/VerifyCsrfToken.php b/app/Http/Middleware/VerifyCsrfToken.php index 0b6761a..0c13b85 100644 --- a/app/Http/Middleware/VerifyCsrfToken.php +++ b/app/Http/Middleware/VerifyCsrfToken.php @@ -1,24 +1,5 @@ . - */ - namespace App\Http\Middleware; use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware; diff --git a/app/Http/Requests/Add2FASecretRequest.php b/app/Http/Requests/Add2FASecretRequest.php index f1b2ca4..13fa9dd 100644 --- a/app/Http/Requests/Add2FASecretRequest.php +++ b/app/Http/Requests/Add2FASecretRequest.php @@ -1,24 +1,5 @@ . - */ - namespace App\Http\Requests; use Illuminate\Foundation\Http\FormRequest; @@ -32,7 +13,7 @@ class Add2FASecretRequest extends FormRequest */ public function authorize() { - // current logic only updates currently authenticated user + // current logic only updates currently authenticated user return true; } @@ -44,7 +25,7 @@ class Add2FASecretRequest extends FormRequest public function rules() { return [ - 'otp' => 'required|string|min:6|max:6', + 'otp' => 'required|string|min:6|max:6' ]; } } diff --git a/app/Http/Requests/BanUserRequest.php b/app/Http/Requests/BanUserRequest.php index 6c0469b..ba25c34 100644 --- a/app/Http/Requests/BanUserRequest.php +++ b/app/Http/Requests/BanUserRequest.php @@ -1,29 +1,11 @@ . - */ - namespace App\Http\Requests; use Illuminate\Foundation\Http\FormRequest; use Illuminate\Support\Facades\Auth; + class BanUserRequest extends FormRequest { /** @@ -46,7 +28,7 @@ class BanUserRequest extends FormRequest return [ 'reason' => 'required|string', 'durationOperand' => 'nullable|string', - 'durationOperator' => 'nullable|string', + 'durationOperator' => 'nullable|string' ]; } } diff --git a/app/Http/Requests/ChangeEmailRequest.php b/app/Http/Requests/ChangeEmailRequest.php index c591f2b..128a3eb 100644 --- a/app/Http/Requests/ChangeEmailRequest.php +++ b/app/Http/Requests/ChangeEmailRequest.php @@ -1,24 +1,5 @@ . - */ - namespace App\Http\Requests; use Illuminate\Foundation\Http\FormRequest; @@ -44,7 +25,7 @@ class ChangeEmailRequest extends FormRequest { return [ 'currentPassword' => 'required|password', - 'newEmail' => 'required|email|unique:users,email', + 'newEmail' => 'required|email|unique:users,email' ]; } } diff --git a/app/Http/Requests/ChangePasswordRequest.php b/app/Http/Requests/ChangePasswordRequest.php index f82dae3..3feb69b 100644 --- a/app/Http/Requests/ChangePasswordRequest.php +++ b/app/Http/Requests/ChangePasswordRequest.php @@ -1,24 +1,5 @@ . - */ - namespace App\Http\Requests; use Illuminate\Foundation\Http\FormRequest; @@ -44,7 +25,7 @@ class ChangePasswordRequest extends FormRequest { return [ 'newPassword' => 'required|string|confirmed', - 'oldPassword' => 'required|string|password', + 'oldPassword' => 'required|string|password' ]; } } diff --git a/app/Http/Requests/DeleteUserRequest.php b/app/Http/Requests/DeleteUserRequest.php index bdaaada..924635c 100644 --- a/app/Http/Requests/DeleteUserRequest.php +++ b/app/Http/Requests/DeleteUserRequest.php @@ -1,24 +1,5 @@ . - */ - namespace App\Http\Requests; use Illuminate\Foundation\Http\FormRequest; @@ -44,7 +25,7 @@ class DeleteUserRequest extends FormRequest public function rules() { return [ - 'confirmPrompt' => 'required|string', + 'confirmPrompt' => 'required|string' ]; } } diff --git a/app/Http/Requests/FlushSessionsRequest.php b/app/Http/Requests/FlushSessionsRequest.php index 6f4c78e..f274ebd 100644 --- a/app/Http/Requests/FlushSessionsRequest.php +++ b/app/Http/Requests/FlushSessionsRequest.php @@ -1,24 +1,5 @@ . - */ - namespace App\Http\Requests; use Illuminate\Foundation\Http\FormRequest; @@ -43,7 +24,7 @@ class FlushSessionsRequest extends FormRequest public function rules() { return [ - 'currentPasswordFlush' => 'required|password', + 'currentPasswordFlush' => 'required|password' ]; } } diff --git a/app/Http/Requests/NewCommentRequest.php b/app/Http/Requests/NewCommentRequest.php index 9d05a95..e1470bc 100644 --- a/app/Http/Requests/NewCommentRequest.php +++ b/app/Http/Requests/NewCommentRequest.php @@ -1,29 +1,11 @@ . - */ - namespace App\Http\Requests; use Illuminate\Foundation\Http\FormRequest; use Illuminate\Support\Facades\Auth; + class NewCommentRequest extends FormRequest { /** @@ -45,7 +27,7 @@ class NewCommentRequest extends FormRequest public function rules() { return [ - 'comment' => 'required|string|max:600|min:20', + 'comment' => 'required|string|max:600|min:20' ]; } } diff --git a/app/Http/Requests/ProfileSave.php b/app/Http/Requests/ProfileSave.php index 7d79846..75278be 100644 --- a/app/Http/Requests/ProfileSave.php +++ b/app/Http/Requests/ProfileSave.php @@ -1,28 +1,10 @@ . - */ - namespace App\Http\Requests; use App\Profile; use Illuminate\Foundation\Http\FormRequest; +use Illuminate\Support\Facades\Auth; class ProfileSave extends FormRequest { @@ -51,7 +33,7 @@ class ProfileSave extends FormRequest 'socialInsta' => 'nullable|string', 'socialTwitter' => 'nullable|string', 'socialDiscord' => 'nullable|string', - 'socialGithub' => 'nullable|string', + 'socialGithub' => 'nullable|string' ]; } } diff --git a/app/Http/Requests/Remove2FASecretRequest.php b/app/Http/Requests/Remove2FASecretRequest.php index 4cd69bb..6583b93 100644 --- a/app/Http/Requests/Remove2FASecretRequest.php +++ b/app/Http/Requests/Remove2FASecretRequest.php @@ -1,24 +1,5 @@ . - */ - namespace App\Http\Requests; use Illuminate\Foundation\Http\FormRequest; @@ -44,7 +25,7 @@ class Remove2FASecretRequest extends FormRequest { return [ 'currentPassword' => 'required|password', - 'consent' => 'required|accepted', + 'consent' => 'required|accepted' ]; } } diff --git a/app/Http/Requests/SaveNotesRequest.php b/app/Http/Requests/SaveNotesRequest.php index 7b89a98..b6dd782 100644 --- a/app/Http/Requests/SaveNotesRequest.php +++ b/app/Http/Requests/SaveNotesRequest.php @@ -1,24 +1,5 @@ . - */ - namespace App\Http\Requests; use Illuminate\Foundation\Http\FormRequest; @@ -43,7 +24,7 @@ class SaveNotesRequest extends FormRequest public function rules() { return [ - 'noteText' => 'required|string', + 'noteText' => 'required|string' ]; } } diff --git a/app/Http/Requests/SearchPlayerRequest.php b/app/Http/Requests/SearchPlayerRequest.php index 23c7e78..4689a49 100644 --- a/app/Http/Requests/SearchPlayerRequest.php +++ b/app/Http/Requests/SearchPlayerRequest.php @@ -1,24 +1,5 @@ . - */ - namespace App\Http\Requests; use Illuminate\Foundation\Http\FormRequest; @@ -44,7 +25,7 @@ class SearchPlayerRequest extends FormRequest public function rules() { return [ - 'searchTerm' => 'required|string|max:17', // max user char limit set by Mojang + 'searchTerm' => 'required|string|max:17' // max user char limit set by Mojang ]; } } diff --git a/app/Http/Requests/UpdateUserRequest.php b/app/Http/Requests/UpdateUserRequest.php index 709f013..99403b4 100644 --- a/app/Http/Requests/UpdateUserRequest.php +++ b/app/Http/Requests/UpdateUserRequest.php @@ -1,24 +1,5 @@ . - */ - namespace App\Http\Requests; use Illuminate\Foundation\Http\FormRequest; @@ -47,7 +28,7 @@ class UpdateUserRequest extends FormRequest 'email' => 'required|email', 'name' => 'required|string', 'uuid' => 'required|max:32|min:32', - 'roles' => 'required_without_all', + 'roles' => 'required_without_all' ]; } } diff --git a/app/Http/Requests/VacancyEditRequest.php b/app/Http/Requests/VacancyEditRequest.php index b9c4c3e..c7ba958 100644 --- a/app/Http/Requests/VacancyEditRequest.php +++ b/app/Http/Requests/VacancyEditRequest.php @@ -1,29 +1,11 @@ . - */ - namespace App\Http\Requests; use Illuminate\Foundation\Http\FormRequest; use Illuminate\Support\Facades\Auth; + class VacancyEditRequest extends FormRequest { /** @@ -46,7 +28,7 @@ class VacancyEditRequest extends FormRequest return [ 'vacancyDescription' => 'required|string', 'vacancyFullDescription' => 'nullable|string', - 'vacancyCount' => 'required|integer|min:1', + 'vacancyCount' => 'required|integer|min:1' ]; } } diff --git a/app/Http/Requests/VacancyRequest.php b/app/Http/Requests/VacancyRequest.php index 07e333c..176610d 100644 --- a/app/Http/Requests/VacancyRequest.php +++ b/app/Http/Requests/VacancyRequest.php @@ -1,24 +1,5 @@ . - */ - namespace App\Http\Requests; use Illuminate\Foundation\Http\FormRequest; @@ -49,7 +30,7 @@ class VacancyRequest extends FormRequest 'permissionGroup' => 'required|string', 'discordRole' => 'required|string', 'vacancyCount' => 'required|integer', - 'vacancyFormID' => 'required|integer', + 'vacancyFormID' => 'required|integer' ]; } } diff --git a/app/Http/Requests/VoteRequest.php b/app/Http/Requests/VoteRequest.php index 67e30a9..fdcf8c9 100644 --- a/app/Http/Requests/VoteRequest.php +++ b/app/Http/Requests/VoteRequest.php @@ -1,24 +1,5 @@ . - */ - namespace App\Http\Requests; use Illuminate\Foundation\Http\FormRequest; @@ -43,7 +24,7 @@ class VoteRequest extends FormRequest public function rules() { return [ - 'voteType' => 'required|string|in:VOTE_DENY,VOTE_APPROVE', + 'voteType' => 'required|string|in:VOTE_DENY,VOTE_APPROVE' ]; } } diff --git a/app/Jobs/CleanBans.php b/app/Jobs/CleanBans.php index 5a25994..a5a6862 100644 --- a/app/Jobs/CleanBans.php +++ b/app/Jobs/CleanBans.php @@ -1,28 +1,7 @@ . - */ - namespace App\Jobs; -use App\Ban; -use Carbon\Carbon; use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Foundation\Bus\Dispatchable; @@ -30,12 +9,15 @@ use Illuminate\Queue\InteractsWithQueue; use Illuminate\Queue\SerializesModels; use Illuminate\Support\Facades\Log; +use App\Ban; +use Carbon\Carbon; + class CleanBans implements ShouldQueue { use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; - public $bans; + public $bans; /** * Create a new job instance. * @@ -52,18 +34,23 @@ class CleanBans implements ShouldQueue */ public function handle() { + Log::debug('Running automatic ban cleaner...'); $bans = Ban::all(); - if (! is_null($bans)) { - foreach ($this->bans as $ban) { - $bannedUntil = Carbon::parse($ban->bannedUntil); + if (!is_null($bans)) + { + foreach($this->bans as $ban) + { + $bannedUntil = Carbon::parse($ban->bannedUntil); - if ($bannedUntil->equalTo(now())) { - Log::debug('Deleted ban '.$ban->id.' belonging to '.$ban->user->name); - $ban->delete(); - } - } + if ($bannedUntil->equalTo(now())) + { + Log::debug('Deleted ban ' . $ban->id . ' belonging to ' . $ban->user->name); + $ban->delete(); + } + } } + } } diff --git a/app/Listeners/DenyUser.php b/app/Listeners/DenyUser.php index 34095ca..0670cc3 100644 --- a/app/Listeners/DenyUser.php +++ b/app/Listeners/DenyUser.php @@ -1,28 +1,11 @@ . - */ - namespace App\Listeners; use App\Events\ApplicationDeniedEvent; use App\Notifications\ApplicationDenied; +use Illuminate\Contracts\Queue\ShouldQueue; +use Illuminate\Queue\InteractsWithQueue; use Illuminate\Support\Facades\Log; class DenyUser @@ -46,8 +29,9 @@ class DenyUser public function handle(ApplicationDeniedEvent $event) { $event->application->setStatus('DENIED'); - Log::info('User '.$event->application->user->name.' just had their application denied.'); + Log::info('User ' . $event->application->user->name . ' just had their application denied.'); $event->application->user->notify(new ApplicationDenied($event->application)); + } } diff --git a/app/Listeners/LogAuthenticationFailure.php b/app/Listeners/LogAuthenticationFailure.php index 15ce404..afe1fee 100644 --- a/app/Listeners/LogAuthenticationFailure.php +++ b/app/Listeners/LogAuthenticationFailure.php @@ -1,26 +1,9 @@ . - */ - namespace App\Listeners; +use Illuminate\Contracts\Queue\ShouldQueue; +use Illuminate\Queue\InteractsWithQueue; use Illuminate\Support\Facades\Log; class LogAuthenticationFailure @@ -44,9 +27,10 @@ class LogAuthenticationFailure public function handle($event) { $targetAccountID = 0; - $originalIP = '0.0.0.0'; + $originalIP = "0.0.0.0"; - if (isset($event->user->id)) { + if (isset($event->user->id)) + { $targetAccountID = $event->user->id; } diff --git a/app/Listeners/LogAuthenticationSuccess.php b/app/Listeners/LogAuthenticationSuccess.php index 7dd3ef3..40781d9 100644 --- a/app/Listeners/LogAuthenticationSuccess.php +++ b/app/Listeners/LogAuthenticationSuccess.php @@ -1,26 +1,9 @@ . - */ - namespace App\Listeners; +use Illuminate\Contracts\Queue\ShouldQueue; +use Illuminate\Queue\InteractsWithQueue; use Illuminate\Support\Facades\Log; class LogAuthenticationSuccess diff --git a/app/Listeners/OnUserBanned.php b/app/Listeners/OnUserBanned.php index 804aac5..897a280 100644 --- a/app/Listeners/OnUserBanned.php +++ b/app/Listeners/OnUserBanned.php @@ -1,31 +1,16 @@ . - */ - namespace App\Listeners; +use Illuminate\Contracts\Queue\ShouldQueue; +use Illuminate\Queue\InteractsWithQueue; use App\Events\UserBannedEvent; use App\Notifications\UserBanned; -use App\User; + use Illuminate\Support\Facades\Log; +use App\User; + class OnUserBanned { /** @@ -46,12 +31,16 @@ class OnUserBanned */ public function handle(UserBannedEvent $event) { - Log::warning('User '.$event->user->name.' has just been banned from the site!'); - foreach (User::all() as $user) { - if ($user->isStaffMember()) { - $user->notify((new UserBanned($event->user, $event->ban))->delay(now()->addSeconds(10))); - } + Log::warning("User " . $event->user->name . " has just been banned from the site!"); + + foreach(User::all() as $user) + { + if ($user->isStaffMember()) + { + $user->notify((new UserBanned($event->user, $event->ban))->delay(now()->addSeconds(10))); + } } + } } diff --git a/app/Listeners/OnUserRegistration.php b/app/Listeners/OnUserRegistration.php index f2fa814..7ab08f9 100644 --- a/app/Listeners/OnUserRegistration.php +++ b/app/Listeners/OnUserRegistration.php @@ -1,30 +1,14 @@ . - */ - namespace App\Listeners; -use App\Notifications\NewUser; -use App\User; -use Illuminate\Auth\Events\Registered; use Illuminate\Support\Facades\Log; +use Illuminate\Auth\Events\Registered; +use Illuminate\Contracts\Queue\ShouldQueue; +use Illuminate\Queue\InteractsWithQueue; + +use App\User; +use App\Notifications\NewUser; class OnUserRegistration { @@ -47,10 +31,12 @@ class OnUserRegistration public function handle(Registered $event) { // TODO: Send push notification to online admins via browser (w/ pusher) - Log::info('User '.$event->user->name.' has just registered for an account.'); + Log::info('User ' . $event->user->name . ' has just registered for an account.'); - foreach (User::all() as $user) { - if ($user->hasRole('admin')) { + foreach(User::all() as $user) + { + if ($user->hasRole('admin')) + { $user->notify(new NewUser($event->user)); } } diff --git a/app/Listeners/PromoteUser.php b/app/Listeners/PromoteUser.php index a3ca047..62760b0 100644 --- a/app/Listeners/PromoteUser.php +++ b/app/Listeners/PromoteUser.php @@ -1,29 +1,13 @@ . - */ - namespace App\Listeners; use App\Events\ApplicationApprovedEvent; -use App\Notifications\ApplicationApproved; use App\StaffProfile; +use App\Notifications\ApplicationApproved; +use Carbon\Carbon; +use Illuminate\Contracts\Queue\ShouldQueue; +use Illuminate\Queue\InteractsWithQueue; use Illuminate\Support\Facades\Log; class PromoteUser @@ -51,18 +35,19 @@ class PromoteUser $staffProfile = StaffProfile::create([ 'userID' => $event->application->user->id, 'approvalDate' => now()->toDateTimeString(), - 'memberNotes' => 'Approved by staff members. Welcome them to the team!', + 'memberNotes' => 'Approved by staff members. Welcome them to the team!' ]); $event->application->user->assignRole('reviewer'); - Log::info('User '.$event->application->user->name.' has just been promoted!', [ + Log::info('User ' . $event->application->user->name . ' has just been promoted!', [ 'newRank' => $event->application->response->vacancy->permissionGroupName, - 'staffProfileID' => $staffProfile->id, + 'staffProfileID' => $staffProfile->id ]); $event->application->user->notify(new ApplicationApproved($event->application)); // note: Also notify staff // TODO: Also assign new app role based on the permission group name + } } diff --git a/app/Mail/NewContactSubmission.php b/app/Mail/NewContactSubmission.php index 15e2cdf..24373f8 100644 --- a/app/Mail/NewContactSubmission.php +++ b/app/Mail/NewContactSubmission.php @@ -1,27 +1,9 @@ . - */ - namespace App\Mail; use Illuminate\Bus\Queueable; +use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Mail\Mailable; use Illuminate\Queue\SerializesModels; diff --git a/app/Notifications/ApplicationApproved.php b/app/Notifications/ApplicationApproved.php index 9c20eae..bfde408 100644 --- a/app/Notifications/ApplicationApproved.php +++ b/app/Notifications/ApplicationApproved.php @@ -1,27 +1,7 @@ . - */ - namespace App\Notifications; -use App\Application; use App\Facades\Options; use App\Traits\Cancellable; use Illuminate\Bus\Queueable; @@ -29,6 +9,7 @@ use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Notifications\Messages\MailMessage; use Illuminate\Notifications\Messages\SlackMessage; use Illuminate\Notifications\Notification; +use App\Application; class ApplicationApproved extends Notification implements ShouldQueue { @@ -64,9 +45,10 @@ class ApplicationApproved extends Notification implements ShouldQueue */ public function toMail($notifiable) { + return (new MailMessage) ->from(config('notification.sender.address'), config('notification.sender.name')) - ->subject(config('app.name').' - '.$this->application->response->vacancy->vacancyName.' application approved') + ->subject(config('app.name') . ' - ' . $this->application->response->vacancy->vacancyName . ' application approved') ->line('
') ->line('Congratulations! Our Staff team has reviewed your application today, and your application has been approved.') ->line('You have just received the Reviewer role, which allows you to view and vote on other applications.') @@ -80,18 +62,19 @@ class ApplicationApproved extends Notification implements ShouldQueue public function toSlack($notifiable) { + $url = route('showSingleProfile', ['user' => $notifiable->id]); $roles = implode(', ', $notifiable->roles->pluck('name')->all()); return (new SlackMessage) ->success() ->content('A user has been approved on the team. Welcome aboard!') - ->attachment(function ($attachment) use ($notifiable, $url, $roles) { + ->attachment(function($attachment) use ($notifiable, $url, $roles){ $attachment->title('New staff member') ->fields([ 'Name' => $notifiable->name, 'Email' => $notifiable->email, - 'Roles' => $roles, + 'Roles' => $roles ]) ->action('View profile', $url); }); diff --git a/app/Notifications/ApplicationDenied.php b/app/Notifications/ApplicationDenied.php index 09233ad..03a4382 100644 --- a/app/Notifications/ApplicationDenied.php +++ b/app/Notifications/ApplicationDenied.php @@ -1,37 +1,19 @@ . - */ - namespace App\Notifications; -use App\Application; use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Notifications\Messages\MailMessage; use Illuminate\Notifications\Messages\SlackMessage; use Illuminate\Notifications\Notification; +use App\Application; class ApplicationDenied extends Notification implements ShouldQueue { use Queueable; + public $application; /** @@ -63,9 +45,10 @@ class ApplicationDenied extends Notification implements ShouldQueue */ public function toMail($notifiable) { + return (new MailMessage) ->from(config('notification.sender.address'), config('notification.sender.name')) - ->subject(config('app.name').' - '.$this->application->response->vacancy->vacancyName.' application denied') + ->subject(config('app.name') . ' - ' . $this->application->response->vacancy->vacancyName . ' application denied') ->line('Your most recent application has been denied.') ->line('Our review team denies applications for several reasons, including poor answers.') ->line('Please review your application and try again in 30 days.') @@ -73,19 +56,20 @@ class ApplicationDenied extends Notification implements ShouldQueue ->line('Better luck next time!'); } + public function toSlack($notifiable) { - $notifiableName = $notifiable->name; + $notifiableName = $notifiable->name; - return (new SlackMessage) + return (new SlackMessage) ->error() ->content('An application has just been denied.') - ->attachment(function ($attachment) use ($notifiableName) { + ->attachment(function($attachment) use ($notifiableName){ $attachment->title('Application denied!') - ->content($notifiableName.'\'s application has just been denied. They can try again in 30 days.'); + ->content($notifiableName . '\'s application has just been denied. They can try again in 30 days.'); }); - } + } /** * Get the array representation of the notification. * diff --git a/app/Notifications/ApplicationMoved.php b/app/Notifications/ApplicationMoved.php index 59c1c63..9598258 100644 --- a/app/Notifications/ApplicationMoved.php +++ b/app/Notifications/ApplicationMoved.php @@ -1,32 +1,13 @@ . - */ - namespace App\Notifications; -use App\Facades\Options; -use App\Traits\Cancellable; use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Notifications\Messages\MailMessage; use Illuminate\Notifications\Notification; +use App\Traits\Cancellable; +use App\Facades\Options; class ApplicationMoved extends Notification implements ShouldQueue { @@ -57,7 +38,7 @@ class ApplicationMoved extends Notification implements ShouldQueue { return (new MailMessage) ->from(config('notification.sender.address'), config('notification.sender.name')) - ->subject(config('app.name').' - Application Updated') + ->subject(config('app.name') . ' - Application Updated') ->line('Your most recent application has been moved up a stage.') ->line('This means our team has reviewed it and an interview will be scheduled ASAP.') ->action('Sign in', url(route('login'))) diff --git a/app/Notifications/AppointmentFinished.php b/app/Notifications/AppointmentFinished.php index 76a54c8..c1e879a 100644 --- a/app/Notifications/AppointmentFinished.php +++ b/app/Notifications/AppointmentFinished.php @@ -1,24 +1,5 @@ . - */ - namespace App\Notifications; use Illuminate\Bus\Queueable; @@ -61,7 +42,7 @@ class AppointmentFinished extends Notification implements ShouldQueue { return (new MailMessage) ->from(config('notification.sender.address'), config('notification.sender.name')) - ->subject(config('app.name').' - Appointment completed') + ->subject(config('app.name') . ' - Appointment completed') ->line('Your appointment has been marked as completed!') ->line('Please allow an additional day for your application to be fully processed.') ->action('View applications', url(route('showUserApps'))) diff --git a/app/Notifications/AppointmentScheduled.php b/app/Notifications/AppointmentScheduled.php index e77cd5d..3ad3f60 100644 --- a/app/Notifications/AppointmentScheduled.php +++ b/app/Notifications/AppointmentScheduled.php @@ -1,36 +1,19 @@ . - */ - namespace App\Notifications; -use App\Appointment; use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Notifications\Messages\MailMessage; use Illuminate\Notifications\Notification; +use App\Appointment; + class AppointmentScheduled extends Notification implements ShouldQueue { use Queueable; + protected $appointment; /** @@ -64,10 +47,10 @@ class AppointmentScheduled extends Notification implements ShouldQueue { return (new MailMessage) ->from(config('notification.sender.address'), config('notification.sender.name')) - ->subject(config('app.name').' - Interview scheduled') - ->line('A voice interview has been scheduled for you @ '.$this->appointment->appointmentDate.'.') - ->line('With the following details: '.$this->appointment->appointmentDescription) - ->line('This meeting will take place @ '.$this->appointment->appointmentLocation.'. You will receive an email soon with details on how to join this meeting.') + ->subject(config('app.name') . ' - Interview scheduled') + ->line('A voice interview has been scheduled for you @ ' . $this->appointment->appointmentDate . '.') + ->line('With the following details: ' . $this->appointment->appointmentDescription) + ->line('This meeting will take place @ ' . $this->appointment->appointmentLocation . '. You will receive an email soon with details on how to join this meeting.') ->line('You are expected to show up at least 5 minutes before the scheduled date.') ->action('Sign in', url(route('login'))) ->line('Thank you!'); diff --git a/app/Notifications/ChangedPassword.php b/app/Notifications/ChangedPassword.php index 6c9bd54..bc4cca5 100644 --- a/app/Notifications/ChangedPassword.php +++ b/app/Notifications/ChangedPassword.php @@ -1,24 +1,5 @@ . - */ - namespace App\Notifications; use Illuminate\Bus\Queueable; @@ -61,7 +42,7 @@ class ChangedPassword extends Notification implements ShouldQueue { return (new MailMessage) ->from(config('notification.sender.address'), config('notification.sender.name')) - ->subject(config('app.name').' - Account password changed') + ->subject(config('app.name') . ' - Account password changed') ->line('The password for the account registered to this email address has just been changed.') ->line('If this was not you, please contact an administrator immediately.') ->action('Sign in', url(route('login'))) diff --git a/app/Notifications/EmailChanged.php b/app/Notifications/EmailChanged.php index 6003cf6..e946102 100644 --- a/app/Notifications/EmailChanged.php +++ b/app/Notifications/EmailChanged.php @@ -1,24 +1,5 @@ . - */ - namespace App\Notifications; use Illuminate\Bus\Queueable; @@ -61,7 +42,7 @@ class EmailChanged extends Notification implements ShouldQueue { return (new MailMessage) ->from(config('notification.sender.address'), config('notification.sender.name')) - ->subject(config('app.name').' - Email address changed') + ->subject(config('app.name') . ' - Email address changed') ->line('The email address for your account has just been updated, either by you or an administrator.') ->action('Sign in', url(route('login'))) ->line('Thank you!'); diff --git a/app/Notifications/NewApplicant.php b/app/Notifications/NewApplicant.php index a0aab57..0fdbac9 100644 --- a/app/Notifications/NewApplicant.php +++ b/app/Notifications/NewApplicant.php @@ -1,42 +1,26 @@ . - */ - namespace App\Notifications; -use App\Application; -use App\Facades\Options; -use App\Traits\Cancellable; -use App\Vacancy; use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Notifications\Messages\MailMessage; use Illuminate\Notifications\Messages\SlackMessage; use Illuminate\Notifications\Notification; +use App\Application; +use App\Vacancy; + +use App\Traits\Cancellable; +use App\Facades\Options; class NewApplicant extends Notification implements ShouldQueue { use Queueable, Cancellable; + protected $application; + protected $vacancy; /** @@ -52,7 +36,8 @@ class NewApplicant extends Notification implements ShouldQueue public function channels() { - if (Options::getOption('enable_slack_notifications') == 1) { + if (Options::getOption('enable_slack_notifications') == 1) + { return ['slack']; } @@ -74,15 +59,17 @@ class NewApplicant extends Notification implements ShouldQueue { return (new MailMessage) ->from(config('notification.sender.address'), config('notification.sender.name')) - ->subject(config('app.name').' - New application') + ->subject(config('app.name') . ' - New application') ->line('Someone has just applied for a position. Check it out!') - ->line('You are receiving this because you\'re a staff member at '.config('app.name').'.') + ->line('You are receiving this because you\'re a staff member at ' . config('app.name') . '.') ->action('View Application', url(route('showUserApp', ['application' => $this->application->id]))) ->line('Thank you!'); } + public function toSlack($notifiable) { + $vacancyDetails = []; $vacancyDetails['name'] = $this->vacancy->vacancyName; $vacancyDetails['slots'] = $this->vacancy->vacancyCount; @@ -93,17 +80,16 @@ class NewApplicant extends Notification implements ShouldQueue return (new SlackMessage) ->success() ->content('Notice: New application coming through. Please review as soon as possible.') - ->attachment(function ($attachment) use ($vacancyDetails, $url, $applicant) { + ->attachment(function($attachment) use ($vacancyDetails, $url, $applicant){ $attachment->title('Application details') ->fields([ - 'Applied for' => $vacancyDetails['name'], - 'Avaiable positions' => $vacancyDetails['slots'], - 'Applicant' => $applicant, + 'Applied for' => $vacancyDetails['name'], + 'Avaiable positions' => $vacancyDetails['slots'], + 'Applicant' => $applicant ]) ->action('Review application', $url); }); } - /** * Get the array representation of the notification. * diff --git a/app/Notifications/NewComment.php b/app/Notifications/NewComment.php index 48e55f9..10c7bfc 100644 --- a/app/Notifications/NewComment.php +++ b/app/Notifications/NewComment.php @@ -1,39 +1,21 @@ . - */ - namespace App\Notifications; -use App\Application; -use App\Comment; -use App\Facades\Options; -use App\Traits\Cancellable; use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Notifications\Messages\MailMessage; use Illuminate\Notifications\Notification; +use App\Comment; +use App\Application; +use App\Traits\Cancellable; +use App\Facades\Options; class NewComment extends Notification implements ShouldQueue { use Queueable, Cancellable; + protected $application; /** @@ -61,7 +43,7 @@ class NewComment extends Notification implements ShouldQueue { return (new MailMessage) ->from(config('notification.sender.address'), config('notification.sender.name')) - ->subject(config('app.name').' - New comment') + ->subject(config('app.name') . ' - New comment') ->line('Someone has just posted a new comment on an application you follow.') ->line('You\'re receiving this email because you\'ve voted/commented on this application.') ->action('Check it out', url(route('showUserApp', ['application' => $this->application->id]))) diff --git a/app/Notifications/NewContact.php b/app/Notifications/NewContact.php index 9526327..761f27c 100644 --- a/app/Notifications/NewContact.php +++ b/app/Notifications/NewContact.php @@ -1,27 +1,9 @@ . - */ - namespace App\Notifications; use Illuminate\Bus\Queueable; +use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Notifications\Messages\MailMessage; use Illuminate\Notifications\Notification; use Illuminate\Support\Collection; @@ -62,22 +44,23 @@ class NewContact extends Notification public function toMail($notifiable) { if ($this->message->has([ - 'message', - 'ip', - 'email', - ])) { - return (new MailMessage) + 'message', + 'ip', + 'email' + ])) + { + return (new MailMessage) ->line('We\'ve received a new contact form submission in the StaffManagement app center.') ->line('This is what they sent: ') ->line('') ->line($this->message->get('message')) ->line('') - ->line('This message was received from '.$this->message->get('ip').' and submitted by '.$this->message->get('email').'.') + ->line('This message was received from ' . $this->message->get('ip') . ' and submitted by ' . $this->message->get('email') . '.') ->action('Sign in', url(route('login'))) ->line('Thank you!'); } - throw new \InvalidArgumentException('Invalid arguments supplied to NewContact!'); + throw new \InvalidArgumentException("Invalid arguments supplied to NewContact!"); } /** diff --git a/app/Notifications/NewUser.php b/app/Notifications/NewUser.php index 1d0db11..ec31cd6 100644 --- a/app/Notifications/NewUser.php +++ b/app/Notifications/NewUser.php @@ -1,35 +1,17 @@ . - */ - namespace App\Notifications; -use App\Facades\Options; -use App\Facades\UUID; -use App\Traits\Cancellable; -use App\User; use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Notifications\Messages\MailMessage; -use Illuminate\Notifications\Messages\SlackMessage; use Illuminate\Notifications\Notification; +use Illuminate\Notifications\Messages\SlackMessage; + +use App\User; +use App\Facades\UUID; +use App\Traits\Cancellable; +use App\Facades\Options; class NewUser extends Notification implements ShouldQueue { @@ -67,8 +49,8 @@ class NewUser extends Notification implements ShouldQueue { return (new MailMessage) ->from(config('notification.sender.address'), config('notification.sender.name')) - ->subject(config('app.name').' - New user') - ->line($this->user->name.' has just registered to our site.') + ->subject(config('app.name') . ' - New user') + ->line($this->user->name . ' has just registered to our site.') ->line('You are receiving this email because you opted to receive new user notifications.') ->action('View profile', url(route('showSingleProfile', ['user' => $this->user->id]))) ->line('Thank you!'); @@ -76,26 +58,28 @@ class NewUser extends Notification implements ShouldQueue public function toSlack($notifiable) { - $user = []; + $user = []; - $user['name'] = $this->user->name; - $user['email'] = $this->user->email; - $user['username'] = UUID::toUsername($this->user->uuid); + $user['name'] = $this->user->name; + $user['email'] = $this->user->email; + $user['username'] = UUID::toUsername($this->user->uuid); - $date = \Carbon\Carbon::parse($this->user->created_at); - $user['created_at'] = $date->englishMonth.' '.$date->day.' '.$date->year; + $date = \Carbon\Carbon::parse($this->user->created_at); + $user['created_at'] = $date->englishMonth . ' ' . $date->day . ' ' . $date->year; return (new SlackMessage) ->success() ->content('A new user has signed up!') - ->attachment(function ($attachment) use ($user) { + ->attachment(function($attachment) use ($user){ + $attachment->title('User details') ->fields([ - 'Email address' => $user['email'], - 'Name' => $user['name'], - 'Minecraft Username' => $user['username'], - 'Registration date' => $user['created_at'], + 'Email address' => $user['email'], + 'Name' => $user['name'], + 'Minecraft Username' => $user['username'], + 'Registration date' => $user['created_at'] ]); + }); } diff --git a/app/Notifications/UserBanned.php b/app/Notifications/UserBanned.php index c230580..f5d5c4e 100644 --- a/app/Notifications/UserBanned.php +++ b/app/Notifications/UserBanned.php @@ -1,33 +1,15 @@ . - */ - namespace App\Notifications; -use App\Ban; -use App\User; use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Notifications\Messages\MailMessage; use Illuminate\Notifications\Notification; +use App\User; +use App\Ban; + class UserBanned extends Notification implements ShouldQueue { use Queueable; @@ -35,7 +17,6 @@ class UserBanned extends Notification implements ShouldQueue protected $user; protected $ban; - /** * Create a new notification instance. * @@ -69,8 +50,8 @@ class UserBanned extends Notification implements ShouldQueue return (new MailMessage) ->from(config('notification.sender.address'), config('notification.sender.name')) ->line('Hello, ') - ->line('Moderators have just banned user '.$this->user->name.' for '.$this->ban->reason) - ->line('This ban will remain in effect until '.$this->ban->bannedUntil.'.') + ->line('Moderators have just banned user ' . $this->user->name . ' for ' . $this->ban->reason) + ->line('This ban will remain in effect until ' . $this->ban->bannedUntil . '.') ->action('View profile', url(route('showSingleProfile', ['user' => $this->user->id]))) ->line('Thank you!'); } diff --git a/app/Notifications/VacancyClosed.php b/app/Notifications/VacancyClosed.php index 4016273..8ae85e4 100644 --- a/app/Notifications/VacancyClosed.php +++ b/app/Notifications/VacancyClosed.php @@ -1,35 +1,17 @@ . - */ - namespace App\Notifications; -use App\Facades\Options; -use App\Traits\Cancellable; -use App\Vacancy; use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Notifications\Messages\MailMessage; use Illuminate\Notifications\Notification; use Illuminate\Queue\SerializesModels; +use App\Vacancy; +use App\Facades\Options; +use App\Traits\Cancellable; + class VacancyClosed extends Notification implements ShouldQueue { use Queueable, SerializesModels, Cancellable; @@ -43,7 +25,7 @@ class VacancyClosed extends Notification implements ShouldQueue */ public function __construct(Vacancy $vacancy) { - $this->vacancy = $vacancy; + $this->vacancy = $vacancy; } public function optOut($notifiable) @@ -61,8 +43,8 @@ class VacancyClosed extends Notification implements ShouldQueue { return (new MailMessage) ->from(config('notification.sender.address'), config('notification.sender.name')) - ->subject(config('app.name').' - Vacancy Closed') - ->line('The vacancy '.$this->vacancy->vacancyName.', with '.$this->vacancy->vacancyCount.' remaining slots, has just been closed.') + ->subject(config('app.name') . ' - Vacancy Closed') + ->line('The vacancy ' . $this->vacancy->vacancyName . ', with ' . $this->vacancy->vacancyCount . ' remaining slots, has just been closed.') ->line('Please be aware that this position may be deleted/reopened any time.') ->action('View positions', url(route('showPositions'))) ->line('Thank you!'); diff --git a/app/Observers/ApplicationObserver.php b/app/Observers/ApplicationObserver.php index 16b6615..8821414 100644 --- a/app/Observers/ApplicationObserver.php +++ b/app/Observers/ApplicationObserver.php @@ -1,24 +1,5 @@ . - */ - namespace App\Observers; use App\Application; @@ -53,20 +34,24 @@ class ApplicationObserver $application->response()->delete(); $votes = $application->votes; - foreach ($votes as $vote) { - Log::debug('Referential integrity cleanup: Deleting and detaching vote '.$vote->id); + foreach ($votes as $vote) + { + Log::debug('Referential integrity cleanup: Deleting and detaching vote ' . $vote->id); $vote->application()->detach($application->id); $vote->delete(); } - if (! is_null($application->appointment)) { + if (!is_null($application->appointment)) + { Log::debug('RIC: Deleting appointment!'); $application->appointment()->delete(); } - if (! $application->comments->isEmpty()) { + if (!$application->comments->isEmpty()) + { Log::debug('RIC: Deleting comments!'); - foreach ($application->comments as $comment) { + foreach($application->comments as $comment) + { $comment->delete(); } } diff --git a/app/Observers/UserObserver.php b/app/Observers/UserObserver.php index 6639504..38f7660 100644 --- a/app/Observers/UserObserver.php +++ b/app/Observers/UserObserver.php @@ -1,24 +1,5 @@ . - */ - namespace App\Observers; use App\Profile; @@ -40,7 +21,7 @@ class UserObserver 'profileShortBio' => 'Write a one-liner about you here!', 'profileAboutMe' => 'Tell us a bit about you.', 'socialLinks' => '{}', - 'userID' => $user->id, + 'userID' => $user->id ]); } @@ -62,12 +43,15 @@ class UserObserver Log::debug('Referential integrity cleanup: Deleted profile!'); $applications = $user->applications; - if (! $applications->isEmpty()) { + if (!$applications->isEmpty()) + { Log::debug('RIC: Now trying to delete applications and responses...'); - foreach ($applications as $application) { + foreach($applications as $application) + { // code moved to Application observer, where it gets rid of attached elements individually - Log::debug('RIC: Deleting application '.$application->id); + Log::debug('RIC: Deleting application ' . $application->id); $application->delete(); + } } diff --git a/app/Observers/VacancyObserver.php b/app/Observers/VacancyObserver.php index c363e15..decf1f7 100644 --- a/app/Observers/VacancyObserver.php +++ b/app/Observers/VacancyObserver.php @@ -1,28 +1,10 @@ . - */ - namespace App\Observers; use App\Vacancy; + class VacancyObserver { /** diff --git a/app/Options.php b/app/Options.php index 895fe88..e650bbc 100644 --- a/app/Options.php +++ b/app/Options.php @@ -1,24 +1,5 @@ . - */ - namespace App; use Illuminate\Database\Eloquent\Model; @@ -27,6 +8,6 @@ class Options extends Model { public $fillable = [ 'option_name', - 'option_value', + 'option_value' ]; } diff --git a/app/Policies/ApplicationPolicy.php b/app/Policies/ApplicationPolicy.php index 6c7c2b9..07edbca 100644 --- a/app/Policies/ApplicationPolicy.php +++ b/app/Policies/ApplicationPolicy.php @@ -1,30 +1,11 @@ . - */ - namespace App\Policies; use App\Application; +use Illuminate\Auth\Access\Response; use App\User; use Illuminate\Auth\Access\HandlesAuthorization; -use Illuminate\Auth\Access\Response; class ApplicationPolicy { @@ -42,20 +23,22 @@ class ApplicationPolicy public function viewAny(User $user) { - if ($user->can('applications.view.all')) { - return Response::allow(); - } + if ($user->can('applications.view.all')) + { + return Response::allow(); + } - return Response::deny('Forbidden'); + return Response::deny('Forbidden'); } public function view(User $user, Application $application) { - if ($user->is($application->user) && $user->can('applications.view.own') || $user->can('applications.view.all')) { - return Response::allow(); - } + if ($user->is($application->user) && $user->can('applications.view.own') || $user->can('applications.view.all')) + { + return Response::allow(); + } - return Response::deny('You are not authorised to view this application'); + return Response::deny('You are not authorised to view this application'); } public function update(User $user) @@ -65,6 +48,8 @@ class ApplicationPolicy public function delete(User $user, Application $application) { - return $user->hasRole('admin'); + + return $user->hasRole('admin'); + } } diff --git a/app/Policies/AppointmentPolicy.php b/app/Policies/AppointmentPolicy.php index 29a5b50..e541e4c 100644 --- a/app/Policies/AppointmentPolicy.php +++ b/app/Policies/AppointmentPolicy.php @@ -1,24 +1,5 @@ . - */ - namespace App\Policies; use App\Appointment; diff --git a/app/Policies/BanPolicy.php b/app/Policies/BanPolicy.php index 0eaa62e..754458e 100644 --- a/app/Policies/BanPolicy.php +++ b/app/Policies/BanPolicy.php @@ -1,24 +1,5 @@ . - */ - namespace App\Policies; use App\Ban; @@ -63,13 +44,12 @@ class BanPolicy */ public function create(User $user, User $targetUser) { - Log::debug('Authorization check started', [ + Log::debug("Authorization check started", [ 'requiredRoles' => 'admin', 'hasRequiredRole' => $user->hasRole('admin'), 'targetUser' => $targetUser->username, - 'isCurrentUser' => Auth::user()->is($user), + 'isCurrentUser' => Auth::user()->is($user) ]); - return $user->hasRole('admin') && $user->isNot($targetUser); } diff --git a/app/Policies/CommentPolicy.php b/app/Policies/CommentPolicy.php index b9ce668..477b445 100644 --- a/app/Policies/CommentPolicy.php +++ b/app/Policies/CommentPolicy.php @@ -1,24 +1,5 @@ . - */ - namespace App\Policies; use App\Comment; @@ -84,7 +65,8 @@ class CommentPolicy */ public function delete(User $user, Comment $comment) { - if ($user->is($comment->user) || $user->hasRole('admin')) { + if ($user->is($comment->user) || $user->hasRole('admin')) + { return true; } diff --git a/app/Policies/FormPolicy.php b/app/Policies/FormPolicy.php index ca6e808..c382190 100644 --- a/app/Policies/FormPolicy.php +++ b/app/Policies/FormPolicy.php @@ -1,24 +1,5 @@ . - */ - namespace App\Policies; use App\Form; @@ -54,9 +35,8 @@ class FormPolicy public function viewFormbuilder(User $user) { - return $user->can('admin.hiring.formbuilder'); + return $user->can('admin.hiring.formbuilder'); } - /** * Determine whether the user can create models. * diff --git a/app/Policies/ProfilePolicy.php b/app/Policies/ProfilePolicy.php index d19801f..bd3bc01 100644 --- a/app/Policies/ProfilePolicy.php +++ b/app/Policies/ProfilePolicy.php @@ -1,24 +1,5 @@ . - */ - namespace App\Policies; use App\Profile; @@ -36,6 +17,7 @@ class ProfilePolicy */ public function __construct() { + } public function edit(User $user, Profile $profile) diff --git a/app/Policies/UserPolicy.php b/app/Policies/UserPolicy.php index f87838a..b98f105 100644 --- a/app/Policies/UserPolicy.php +++ b/app/Policies/UserPolicy.php @@ -1,24 +1,5 @@ . - */ - namespace App\Policies; use App\User; @@ -35,6 +16,7 @@ class UserPolicy */ public function __construct() { + } public function edit(User $authUser, User $user) @@ -45,7 +27,7 @@ class UserPolicy // This refers to the admin tools that let staff update more information than users themselves can public function adminEdit(User $authUser, User $user) { - return $authUser->hasRole('admin') && $authUser->isNot($user); + return $authUser->hasRole('admin') && $authUser->isNot($user); } public function viewStaff(User $user) @@ -60,11 +42,11 @@ class UserPolicy public function terminate(User $authUser) { - return $authUser->hasRole('admin'); + return $authUser->hasRole('admin'); } public function delete(User $authUser, User $subject) { - return $authUser->hasRole('admin') && $authUser->isNot($subject); + return $authUser->hasRole('admin') && $authUser->isNot($subject); } } diff --git a/app/Policies/VacancyPolicy.php b/app/Policies/VacancyPolicy.php index 3ff57ad..7e547f2 100644 --- a/app/Policies/VacancyPolicy.php +++ b/app/Policies/VacancyPolicy.php @@ -1,24 +1,5 @@ . - */ - namespace App\Policies; use App\User; @@ -29,7 +10,6 @@ class VacancyPolicy { use HandlesAuthorization; // TODO: Switch to permissions (there are no specific permissions yet) - /** * Determine whether the user can view any models. * diff --git a/app/Policies/VotePolicy.php b/app/Policies/VotePolicy.php index 570e145..9337aa4 100644 --- a/app/Policies/VotePolicy.php +++ b/app/Policies/VotePolicy.php @@ -1,24 +1,5 @@ . - */ - namespace App\Policies; use App\User; diff --git a/app/Profile.php b/app/Profile.php index 0367189..9a64243 100644 --- a/app/Profile.php +++ b/app/Profile.php @@ -1,37 +1,19 @@ . - */ - namespace App; use Illuminate\Database\Eloquent\Model; class Profile extends Model { + public $fillable = [ 'profileShortBio', 'profileAboutMe', 'avatarPreference', 'socialLinks', - 'userID', + 'userID' ]; @@ -39,4 +21,5 @@ class Profile extends Model { return $this->belongsTo('App\User', 'userID', 'id'); } + } diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index cef8e40..8d8144e 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -1,24 +1,5 @@ . - */ - namespace App\Providers; use App\Application; @@ -49,7 +30,7 @@ class AppServiceProvider extends ServiceProvider public function boot() { Sentry\init([ - 'release' => env('RELEASE'), + 'release' => env('RELEASE') ]); Schema::defaultStringLength(191); diff --git a/app/Providers/AuthServiceProvider.php b/app/Providers/AuthServiceProvider.php index ee9ecfd..52563b4 100644 --- a/app/Providers/AuthServiceProvider.php +++ b/app/Providers/AuthServiceProvider.php @@ -1,42 +1,27 @@ . - */ - namespace App\Providers; +use App\Policies\ProfilePolicy; +use App\Policies\VacancyPolicy; +use App\Policies\UserPolicy; +use App\Policies\BanPolicy; +use App\Policies\FormPolicy; +use App\Policies\VotePolicy; +use App\Policies\ApplicationPolicy; +use App\Policies\AppointmentPolicy; + +use App\User; +use App\Form; +use App\Vote; +use App\Vacancy; use App\Application; use App\Appointment; use App\Ban; -use App\Form; -use App\Policies\ApplicationPolicy; -use App\Policies\AppointmentPolicy; -use App\Policies\BanPolicy; -use App\Policies\FormPolicy; -use App\Policies\ProfilePolicy; -use App\Policies\UserPolicy; -use App\Policies\VacancyPolicy; -use App\Policies\VotePolicy; -use App\User; -use App\Vacancy; -use App\Vote; + + use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider; +use Illuminate\Support\Facades\Gate; class AuthServiceProvider extends ServiceProvider { @@ -55,7 +40,7 @@ class AuthServiceProvider extends ServiceProvider 'App\Form' => 'App\Policies\FormPolicy', Vote::class => VotePolicy::class, Ban::class => BanPolicy::class, - Appointment::class => AppointmentPolicy::class, + Appointment::class => AppointmentPolicy::class ]; /** diff --git a/app/Providers/BroadcastServiceProvider.php b/app/Providers/BroadcastServiceProvider.php index f3d62bd..395c518 100644 --- a/app/Providers/BroadcastServiceProvider.php +++ b/app/Providers/BroadcastServiceProvider.php @@ -1,24 +1,5 @@ . - */ - namespace App\Providers; use Illuminate\Support\Facades\Broadcast; diff --git a/app/Providers/ContextAwareValidatorProvider.php b/app/Providers/ContextAwareValidatorProvider.php index bc4f309..749de88 100644 --- a/app/Providers/ContextAwareValidatorProvider.php +++ b/app/Providers/ContextAwareValidatorProvider.php @@ -1,29 +1,11 @@ . - */ - namespace App\Providers; -use App; use Illuminate\Support\ServiceProvider; +use App; + class ContextAwareValidatorProvider extends ServiceProvider { /** @@ -43,8 +25,10 @@ class ContextAwareValidatorProvider extends ServiceProvider */ public function boot() { - App::bind('contextAwareValidator', function () { - return new App\Helpers\ContextAwareValidator(); - }); + App::bind('contextAwareValidator', function(){ + + return new App\Helpers\ContextAwareValidator(); + + }); } } diff --git a/app/Providers/EventServiceProvider.php b/app/Providers/EventServiceProvider.php index 11b6295..6ea787f 100644 --- a/app/Providers/EventServiceProvider.php +++ b/app/Providers/EventServiceProvider.php @@ -1,24 +1,5 @@ . - */ - namespace App\Providers; use App\Listeners\LogAuthenticationFailure; @@ -41,23 +22,23 @@ class EventServiceProvider extends ServiceProvider protected $listen = [ Registered::class => [ SendEmailVerificationNotification::class, - OnUserRegistration::class, + OnUserRegistration::class ], Failed::class => [ - LogAuthenticationFailure::class, + LogAuthenticationFailure::class ], Login::class => [ - LogAuthenticationSuccess::class, + LogAuthenticationSuccess::class ], 'App\Events\ApplicationApprovedEvent' => [ - 'App\Listeners\PromoteUser', + 'App\Listeners\PromoteUser' ], 'App\Events\ApplicationDeniedEvent' => [ - 'App\Listeners\DenyUser', + 'App\Listeners\DenyUser' ], 'App\Events\UserBannedEvent' => [ - 'App\Listeners\OnUserBanned', - ], + 'App\Listeners\OnUserBanned' + ] ]; /** @@ -67,6 +48,7 @@ class EventServiceProvider extends ServiceProvider */ public function boot() { + parent::boot(); // diff --git a/app/Providers/IPInfoProvider.php b/app/Providers/IPInfoProvider.php index 5ebe6f8..3b7150a 100644 --- a/app/Providers/IPInfoProvider.php +++ b/app/Providers/IPInfoProvider.php @@ -1,28 +1,9 @@ . - */ - namespace App\Providers; -use App; use Illuminate\Support\ServiceProvider; +use App; class IPInfoProvider extends ServiceProvider { @@ -43,8 +24,10 @@ class IPInfoProvider extends ServiceProvider */ public function boot() { - App::bind('ipInformationFacade', function () { + App::bind('ipInformationFacade', function(){ + return new App\CustomFacades\IP(); + }); } } diff --git a/app/Providers/MojangStatusProvider.php b/app/Providers/MojangStatusProvider.php index 84bb47d..3fe4dc1 100644 --- a/app/Providers/MojangStatusProvider.php +++ b/app/Providers/MojangStatusProvider.php @@ -1,32 +1,13 @@ . - */ - namespace App\Providers; use GuzzleHttp\Exception\ConnectException; use Illuminate\Support\Facades\Cache; use Illuminate\Support\Facades\Http; use Illuminate\Support\Facades\Log; -use Illuminate\Support\Facades\View; use Illuminate\Support\ServiceProvider; +use Illuminate\Support\Facades\View; class MojangStatusProvider extends ServiceProvider { @@ -48,15 +29,19 @@ class MojangStatusProvider extends ServiceProvider public function boot() { // TODO: (IMPORTANT) Switch this to Middleware - if (! Cache::has('mojang_status')) { - Log::info('Mojang Status Provider: Mojang Status not found in the cache; Sending new request.'); + if (!Cache::has('mojang_status')) + { + Log::info("Mojang Status Provider: Mojang Status not found in the cache; Sending new request."); - try { + try + { $mcstatus = Http::get(config('general.urls.mojang.statuscheck')); Cache::put('mojang_status', base64_encode($mcstatus->body()), now()->addDays(3)); - } catch (ConnectException $connectException) { + } + catch(ConnectException $connectException) + { Log::critical('Could not connect to Mojang servers: Cannot check/refresh status', [ - 'message' => $connectException->getMessage(), + 'message' => $connectException->getMessage() ]); } } diff --git a/app/Providers/OptionsProvider.php b/app/Providers/OptionsProvider.php index 7c70e8e..3bc98db 100644 --- a/app/Providers/OptionsProvider.php +++ b/app/Providers/OptionsProvider.php @@ -1,28 +1,9 @@ . - */ - namespace App\Providers; -use App; use Illuminate\Support\ServiceProvider; +use App; class OptionsProvider extends ServiceProvider { @@ -43,7 +24,7 @@ class OptionsProvider extends ServiceProvider */ public function boot() { - App::bind('smOptions', function () { + App::bind('smOptions', function (){ return new App\Helpers\Options(); }); } diff --git a/app/Providers/RouteServiceProvider.php b/app/Providers/RouteServiceProvider.php index eab8bbb..1235909 100644 --- a/app/Providers/RouteServiceProvider.php +++ b/app/Providers/RouteServiceProvider.php @@ -1,24 +1,5 @@ . - */ - namespace App\Providers; use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider; diff --git a/app/Providers/UUIDConversionProvider.php b/app/Providers/UUIDConversionProvider.php index 7f26d6b..6ce7fad 100644 --- a/app/Providers/UUIDConversionProvider.php +++ b/app/Providers/UUIDConversionProvider.php @@ -1,28 +1,9 @@ . - */ - namespace App\Providers; -use App; use Illuminate\Support\ServiceProvider; +use App; class UUIDConversionProvider extends ServiceProvider { @@ -43,8 +24,10 @@ class UUIDConversionProvider extends ServiceProvider */ public function boot() { - App::bind('uuidConversionFacade', function () { + App::bind('uuidConversionFacade', function(){ + return new App\UUID\UUID(); + }); } } diff --git a/app/Response.php b/app/Response.php index dfa96d0..08312ea 100644 --- a/app/Response.php +++ b/app/Response.php @@ -1,24 +1,5 @@ . - */ - namespace App; use Illuminate\Database\Eloquent\Model; @@ -28,9 +9,10 @@ class Response extends Model public $fillable = [ 'responseFormID', 'associatedVacancyID', - 'responseData', + 'responseData' ]; + public function form() { return $this->hasOne('App\Form', 'id', 'responseFormID'); diff --git a/app/StaffProfile.php b/app/StaffProfile.php index 87d131b..8d6cfba 100644 --- a/app/StaffProfile.php +++ b/app/StaffProfile.php @@ -1,24 +1,5 @@ . - */ - namespace App; use Illuminate\Database\Eloquent\Model; @@ -31,7 +12,7 @@ class StaffProfile extends Model 'approvalDate', 'terminationDate', 'resignationDate', - 'memberNotes', + 'memberNotes' ]; } diff --git a/app/Traits/AuthenticatesTwoFactor.php b/app/Traits/AuthenticatesTwoFactor.php index 9a36d51..4b6ab31 100644 --- a/app/Traits/AuthenticatesTwoFactor.php +++ b/app/Traits/AuthenticatesTwoFactor.php @@ -1,54 +1,40 @@ . - */ - namespace App\Traits; -use App\Http\Requests\Add2FASecretRequest; use Google2FA; +use App\Http\Requests\Add2FASecretRequest; use Illuminate\Support\Facades\Log; + trait AuthenticatesTwoFactor { + public function verify2FA(Add2FASecretRequest $request) { $isValid = Google2FA::verifyKey($request->user()->twofa_secret, $request->otp); - if ($isValid) { - Google2FA::login(); + if ($isValid) + { + Google2FA::login(); - Log::info('SECURITY (postauth): One-time password verification succeeded', [ - 'initiator' => $request->user()->email, - 'ip' => $request->ip(), - ]); + Log::info('SECURITY (postauth): One-time password verification succeeded', [ + 'initiator' => $request->user()->email, + 'ip' => $request->ip() + ]); - return redirect()->to($this->redirectTo); - } else { - Log::warning('SECURITY (preauth): One-time password verification failed', [ - 'initiator' => $request->user()->email, - 'ip' => $request->ip(), - ]); + return redirect()->to($this->redirectTo); + } + else + { + Log::warning('SECURITY (preauth): One-time password verification failed', [ + 'initiator' => $request->user()->email, + 'ip' => $request->ip() + ]); - $request->session()->flash('error', 'Your one time password is invalid.'); - - return redirect()->back(); + $request->session()->flash('error', 'Your one time password is invalid.'); + return redirect()->back(); } } + } diff --git a/app/Traits/Cancellable.php b/app/Traits/Cancellable.php index 53a9e37..cbccb67 100644 --- a/app/Traits/Cancellable.php +++ b/app/Traits/Cancellable.php @@ -1,37 +1,24 @@ . - */ namespace App\Traits; + use App\Facades\Options; trait Cancellable { + public function chooseChannelsViaOptions() { $channels = []; - if (Options::getOption('enable_slack_notifications') == 1) { + if (Options::getOption('enable_slack_notifications') == 1) + { array_push($channels, 'slack'); - } elseif (Options::getOption('enable_email_notifications') == 1) { + } + elseif(Options::getOption('enable_email_notifications') == 1) + { array_push($channels, 'email'); } @@ -45,15 +32,18 @@ trait Cancellable public function via($notifiable) { - if ($this->optOut($notifiable)) { + if ($this->optOut($notifiable)) + { return []; } return $this->channels(); } + public function optOut($notifiable) { return false; } + } diff --git a/app/UUID/UUID.php b/app/UUID/UUID.php index 2a4de20..cee10d1 100644 --- a/app/UUID/UUID.php +++ b/app/UUID/UUID.php @@ -1,66 +1,59 @@ . - */ + namespace App\UUID; -use Illuminate\Support\Facades\Cache; use Illuminate\Support\Facades\Http; +use Illuminate\Support\Facades\Cache; use Illuminate\Support\Facades\Log; class UUID { + // Caching would not be needed here since this method won't be used in pages that loop over a collection of usernames. public function toUUID($username) { - if (is_null($username)) { - throw new \LogicException('Argument username for '.__METHOD__.' cannot be null!'); + if (is_null($username)) + { + throw new \LogicException('Argument username for ' . __METHOD__ . ' cannot be null!'); } - $response = json_decode(Http::post(trim(config('general.urls.mojang.api')).'/profiles/minecraft', [ - $username, + $response = json_decode(Http::post(trim(config('general.urls.mojang.api')) . '/profiles/minecraft', [ + $username ])->body(), true); - if (isset($response[0])) { - return $response[0]['id']; + if (isset($response[0])) + { + return $response[0]['id']; + } - throw new \InvalidArgumentException('You must supply a valid, premium Minecraft account to sign up.'); + throw new \InvalidArgumentException("You must supply a valid, premium Minecraft account to sign up."); } // Note: Caching could simply be assigning the username to it's UUID, however, to make this work, we'd need to loop over all cache items, which would be slighly ineffective public function toUsername($uuid) { - if (is_null($uuid)) { - throw new \LogicException('Argument uuid for '.__METHOD__.' cannot be null!'); + + if (is_null($uuid)) + { + throw new \LogicException('Argument uuid for ' . __METHOD__ . ' cannot be null!'); } - $shortUUID = substr($uuid, 0, 8); - $username = Cache::remember('uuid_'.$shortUUID, now()->addDays(30), function () use ($shortUUID, $uuid) { - $response = json_decode(Http::get(trim(config('general.urls.mojang.session')).'/session/minecraft/profile/'.$uuid)->body(), true); + $shortUUID = substr($uuid, 0, 8); + $username = Cache::remember('uuid_' . $shortUUID, now()->addDays(30), function() use ($shortUUID, $uuid) { - Log::debug('Caching '.$shortUUID.'for thirty days'); + $response = json_decode(Http::get(trim(config('general.urls.mojang.session')) . '/session/minecraft/profile/' . $uuid)->body(), true); + Log::debug('Caching ' . $shortUUID . 'for thirty days'); return $response['name']; - }); - return $username; + }); + + return $username; + } + + } diff --git a/app/User.php b/app/User.php index fc55a40..06f555f 100644 --- a/app/User.php +++ b/app/User.php @@ -1,24 +1,5 @@ . - */ - namespace App; use Illuminate\Contracts\Auth\MustVerifyEmail; @@ -37,7 +18,7 @@ class User extends Authenticatable implements MustVerifyEmail * @var array */ protected $fillable = [ - 'name', 'email', 'password', 'originalIP', 'username', 'uuid', 'dob', + 'name', 'email', 'password', 'originalIP', 'username', 'uuid', 'dob' ]; /** @@ -58,6 +39,7 @@ class User extends Authenticatable implements MustVerifyEmail 'email_verified_at' => 'datetime', ]; + // public function applications() { @@ -84,11 +66,15 @@ class User extends Authenticatable implements MustVerifyEmail return $this->hasMany('App\Comment', 'authorID', 'id'); } + public function isBanned() { - return ! $this->bans()->get()->isEmpty(); + return !$this->bans()->get()->isEmpty(); } + + + public function isStaffMember() { return $this->hasAnyRole('reviewer', 'admin', 'hiringManager'); @@ -96,11 +82,13 @@ class User extends Authenticatable implements MustVerifyEmail public function has2FA() { - return ! is_null($this->twofa_secret); + return !is_null($this->twofa_secret); } + + public function routeNotificationForSlack($notification) { - return config('slack.webhook.integrationURL'); + return config('slack.webhook.integrationURL'); } } diff --git a/app/Vacancy.php b/app/Vacancy.php index 476e14e..1a84996 100644 --- a/app/Vacancy.php +++ b/app/Vacancy.php @@ -1,31 +1,14 @@ . - */ - namespace App; -use GrahamCampbell\Markdown\Facades\Markdown; use Illuminate\Database\Eloquent\Model; use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Log; +use GrahamCampbell\Markdown\Facades\Markdown; + + class Vacancy extends Model { public $fillable = [ @@ -38,25 +21,30 @@ class Vacancy extends Model 'vacancyFormID', 'vacancyCount', 'vacancyStatus', - 'vacancySlug', + 'vacancySlug' ]; + /** - * Get the HTML variant of the vacancyFullDescription attribute. - * - * @param string $value The original value - * @return string - */ + * Get the HTML variant of the vacancyFullDescription attribute. + * + * @param string $value The original value + * @return string + */ public function getVacancyFullDescriptionAttribute($value) { - if (! is_null($value)) { - return Markdown::convertToHTML($value); - } else { - return null; + if (!is_null($value)) + { + return Markdown::convertToHTML($value); + } + else + { + return null; } } + public function forms() { return $this->belongsTo('App\Form', 'vacancyFormID', 'id'); @@ -65,18 +53,20 @@ class Vacancy extends Model public function open() { $this->update([ - 'vacancyStatus' => 'OPEN', + 'vacancyStatus' => 'OPEN' ]); - Log::info('Vacancies: Vacancy '.$this->id.' ('.$this->vacancyName.') opened by '.Auth::user()->name); + Log::info("Vacancies: Vacancy " . $this->id . " (" . $this->vacancyName . ") opened by " . Auth::user()->name); } public function close() { $this->update([ - 'vacancyStatus' => 'CLOSED', + 'vacancyStatus' => 'CLOSED' ]); - Log::warning('Vacancies: Vacancy '.$this->id.' ('.$this->vacancyName.') closed by '.Auth::user()->name); + Log::warning("Vacancies: Vacancy " . $this->id . " (" . $this->vacancyName . ") closed by " . Auth::user()->name); + } + } diff --git a/app/View/Components/Alert.php b/app/View/Components/Alert.php index be497b4..04b5f3c 100644 --- a/app/View/Components/Alert.php +++ b/app/View/Components/Alert.php @@ -1,30 +1,12 @@ . - */ - namespace App\View\Components; use Illuminate\View\Component; class Alert extends Component { + public $alertType; public $extraStyling; diff --git a/app/View/Components/Card.php b/app/View/Components/Card.php index ee20d0d..6a5a953 100644 --- a/app/View/Components/Card.php +++ b/app/View/Components/Card.php @@ -1,24 +1,5 @@ . - */ - namespace App\View\Components; use Illuminate\View\Component; @@ -27,10 +8,14 @@ class Card extends Component { public $id; + public $cardTitle; + + public $footerStyle; + /** * Create a new component instance. * diff --git a/app/View/Components/Form.php b/app/View/Components/Form.php index 821ea5d..06e868d 100644 --- a/app/View/Components/Form.php +++ b/app/View/Components/Form.php @@ -1,34 +1,16 @@ . - */ - namespace App\View\Components; use Illuminate\View\Component; class Form extends Component { + public $formFields; - public $disableFields = false; + public $disableFields = false; /** * Create a new component instance. * @@ -36,7 +18,7 @@ class Form extends Component */ public function __construct($disableFields = false) { - $this->disableFields = $disableFields; + $this->disableFields = $disableFields; } /** diff --git a/app/View/Components/GlobalErrors.php b/app/View/Components/GlobalErrors.php index 5360e13..ab130be 100644 --- a/app/View/Components/GlobalErrors.php +++ b/app/View/Components/GlobalErrors.php @@ -1,24 +1,5 @@ . - */ - namespace App\View\Components; use Illuminate\View\Component; diff --git a/app/View/Components/Modal.php b/app/View/Components/Modal.php index fd23b3f..4ab43d3 100644 --- a/app/View/Components/Modal.php +++ b/app/View/Components/Modal.php @@ -1,24 +1,5 @@ . - */ - namespace App\View\Components; use Illuminate\View\Component; @@ -27,10 +8,13 @@ class Modal extends Component { public $id; + public $modalLabel; + public $modalTitle; + public $includeCloseButton; /** diff --git a/app/View/Components/NoPermission.php b/app/View/Components/NoPermission.php index f55f30a..6da51a1 100644 --- a/app/View/Components/NoPermission.php +++ b/app/View/Components/NoPermission.php @@ -1,24 +1,5 @@ . - */ - namespace App\View\Components; use Illuminate\View\Component; @@ -28,7 +9,6 @@ class NoPermission extends Component public $type; public $inDashboard; - /** * Create a new component instance. * @@ -36,9 +16,9 @@ class NoPermission extends Component */ public function __construct($type, $inDashboard = true) { - $this->type = $type; + $this->type = $type; - $this->inDashboard = $inDashboard; + $this->inDashboard = $inDashboard; } /** diff --git a/app/Vote.php b/app/Vote.php index 74a5aa0..6a89b21 100644 --- a/app/Vote.php +++ b/app/Vote.php @@ -1,24 +1,5 @@ . - */ - namespace App; use Illuminate\Database\Eloquent\Model; @@ -33,7 +14,7 @@ class Vote extends Model ]; public $touches = [ - 'application', + 'application' ]; public function user() diff --git a/bootstrap/app.php b/bootstrap/app.php index c89db0b..037e17d 100644 --- a/bootstrap/app.php +++ b/bootstrap/app.php @@ -1,23 +1,15 @@ . - */ +|-------------------------------------------------------------------------- +| Create The Application +|-------------------------------------------------------------------------- +| +| The first thing we will do is create a new Laravel application instance +| which serves as the "glue" for all the components of Laravel, and is +| the IoC container for the system binding all of the various parts. +| +*/ $app = new Illuminate\Foundation\Application( $_ENV['APP_BASE_PATH'] ?? dirname(__DIR__) diff --git a/config/adminlte.php b/config/adminlte.php index 867c604..9c71a48 100644 --- a/config/adminlte.php +++ b/config/adminlte.php @@ -1,24 +1,5 @@ . - */ - return [ /* @@ -69,7 +50,7 @@ return [ 'logo_img_class' => 'brand-image img-circle elevation-3', 'logo_img_xl' => null, 'logo_img_xl_class' => 'brand-image-xs', - 'logo_img_alt' => env('APP_NAME').'\'s Temporary Logo', + 'logo_img_alt' => env('APP_NAME') . '\'s Temporary Logo', /* |-------------------------------------------------------------------------- @@ -230,17 +211,17 @@ return [ [ 'text' => 'm_home', 'icon' => 'fas fa-home', - 'url' => 'dashboard', + 'url' => 'dashboard' ], [ 'text' => 'm_directory', 'icon' => 'fas fa-users', 'url' => 'users/directory', - 'can' => 'profiles.view.others', + 'can' => 'profiles.view.others' ], [ 'header' => 'h_applications', - 'can' => 'applications.view.own', + 'can' => 'applications.view.own' ], [ 'text' => 'm_my_applications', @@ -250,8 +231,8 @@ return [ [ 'text' => 'm_curr_applications', 'icon' => 'fas fa-fw fa-check-double', - 'url' => '/applications/my-applications', - ], + 'url' => '/applications/my-applications' + ] ], ], @@ -261,40 +242,40 @@ return [ [ 'text' => 'm_profile_settings', 'url' => '/profile/settings', - 'icon' => 'fas fa-fw fa-cog', + 'icon' => 'fas fa-fw fa-cog' ], [ 'text' => 'm_account_settings', 'icon' => 'fas fa-user-circle', - 'url' => '/profile/settings/account', + 'url' => '/profile/settings/account' ], [ 'header' => 'h_app_management', - 'can' => ['applications.view.all', 'applications.vote'], + 'can' => ['applications.view.all', 'applications.vote'] ], [ 'text' => 'm_all_apps', 'url' => 'applications/staff/all', 'icon' => 'fas fa-list-ol', - 'can' => 'applications.view.all', + 'can' => 'applications.view.all' ], [ 'text' => 'm_outstanding_apps', 'url' => '/applications/staff/outstanding', 'icon' => 'far fa-folder-open', - 'can' => 'applications.view.all', + 'can' => 'applications.view.all' ], [ 'text' => 'm_interview_queue', 'url' => '/applications/staff/pending-interview', 'icon' => 'fas fa-fw fa-microphone-alt', - 'can' => 'applications.view.all', + 'can' => 'applications.view.all' ], [ 'text' => 'm_peer_approval', 'url' => '/applications/staff/peer-review', 'icon' => 'fas fa-fw fa-search', - 'can' => 'applications.view.all', + 'can' => 'applications.view.all' ], [ 'header' => 'h_admin', @@ -303,20 +284,20 @@ return [ 'admin.userlist', 'admin.stafflist', 'admin.hiring.*', - 'admin.notificationsettings.*', - ], + 'admin.notificationsettings.*' + ] ], [ 'text' => 'm_staff_m', 'icon' => 'fas fa-fw fa-users', 'url' => '/hr/staff-members', - 'can' => 'admin.stafflist', + 'can' => 'admin.stafflist' ], [ // players who haven't been promoted yet 'text' => 'm_reg_players', 'icon' => 'fas fa-fw fa-user-friends', 'url' => '/hr/players', - 'can' => 'admin.userlist', + 'can' => 'admin.userlist' ], [ 'text' => 'sm_hiring_man', @@ -326,7 +307,7 @@ return [ [ 'text' => 'm_open_pos', 'icon' => 'fas fa-box-open', - 'url' => '/admin/positions', + 'url' => '/admin/positions' ], [ 'text' => 'sm_forms', @@ -335,16 +316,16 @@ return [ [ 'text' => 'sm_all_forms', 'icon' => 'far fa-list-alt', - 'url' => '/admin/forms', + 'url' => '/admin/forms' ], [ 'text' => 'm_form_builder', 'icon' => 'fas fa-fw fa-hammer', - 'url' => '/admin/forms/builder', - ], - ], - ], - ], + 'url' => '/admin/forms/builder' + ] + ] + ] + ] ], [ 'text' => 'sm_app_settings', @@ -355,22 +336,22 @@ return [ 'text' => 'm_global_app_s', 'icon' => 'fas fa-cogs', 'url' => '/admin/settings', - 'can' => 'admin.settings.view', + 'can' => 'admin.settings.view' ], [ 'text' => 'm_devtools', 'icon' => 'fas fa-code', 'url' => '/admin/devtools', - 'can' => 'admin.developertools.use', - ], - ], + 'can' => 'admin.developertools.use' + ] + ] ], [ 'text' => 'm_s_logs', 'url' => '/admin/maintenance/system-logs', 'icon' => 'fas fa-clipboard-list', - 'can' => 'admin.maintenance.logs.view', - ], + 'can' => 'admin.maintenance.logs.view' + ] ], /* @@ -436,9 +417,9 @@ return [ [ 'type' => 'js', 'asset' => false, - 'location' => '/js/formbuilder.js', - ], - ], + 'location' => '/js/formbuilder.js' + ] + ] ], [ 'name' => 'Select2', @@ -501,14 +482,14 @@ return [ [ 'type' => 'js', 'asset' => false, - 'location' => 'https://cdn.jsdelivr.net/npm/toastr@2.1.4/toastr.min.js', + 'location' => 'https://cdn.jsdelivr.net/npm/toastr@2.1.4/toastr.min.js' ], [ 'type' => 'css', 'asset' => false, - 'location' => 'https://cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/toastr.min.css', - ], - ], + 'location' => 'https://cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/toastr.min.css' + ] + ] ], [ 'name' => 'GlobalTooltip', @@ -517,9 +498,9 @@ return [ [ 'type' => 'js', 'asset' => false, - 'location' => '/js/globaltooltip.js', - ], - ], + 'location' => '/js/globaltooltip.js' + ] + ] ], [ 'name' => 'DatePickApp', @@ -528,36 +509,36 @@ return [ [ 'type' => 'js', 'asset' => false, - 'location' => '/js/datepick.js', - ], - ], + 'location' => '/js/datepick.js' + ] + ] ], [ - 'name' => 'Fullcalendar', - 'active' => true, - 'files' => [ - [ - 'type' => 'js', - 'asset' => false, - 'location' => 'https://cdn.jsdelivr.net/npm/fullcalendar@5.0.1/main.min.js', - ], - [ - 'type' => 'css', - 'asset' => false, - 'location' => 'https://cdn.jsdelivr.net/npm/fullcalendar@5.0.1/main.min.css', - ], + 'name' => 'Fullcalendar', + 'active' => true, + 'files' => [ + [ + 'type' => 'js', + 'asset' => false, + 'location' => 'https://cdn.jsdelivr.net/npm/fullcalendar@5.0.1/main.min.js', ], + [ + 'type' => 'css', + 'asset' => false, + 'location' => 'https://cdn.jsdelivr.net/npm/fullcalendar@5.0.1/main.min.css' + ] + ] ], [ - 'name' => 'AuthCustomisations', - 'active' => true, - 'files' => [ - [ - 'type' => 'css', - 'asset' => false, - 'location' => '/css/authpages.css', - ], - ], - ], + 'name' => 'AuthCustomisations', + 'active' => true, + 'files' => [ + [ + 'type' => 'css', + 'asset' => false, + 'location' => '/css/authpages.css' + ] + ] + ] ], ]; diff --git a/config/app.php b/config/app.php index 188a5ba..96e5484 100644 --- a/config/app.php +++ b/config/app.php @@ -1,24 +1,5 @@ . - */ - return [ /* @@ -34,6 +15,7 @@ return [ 'name' => env('APP_NAME', 'Laravel'), + /* |-------------------------------------------------------------------------- | Application Homepage @@ -211,7 +193,7 @@ return [ App\Providers\EventServiceProvider::class, App\Providers\RouteServiceProvider::class, \App\Providers\MojangStatusProvider::class, - \App\Providers\OptionsProvider::class, + \App\Providers\OptionsProvider::class ], @@ -268,7 +250,7 @@ return [ 'IP' => App\Facades\IP::class, 'Markdown' => GrahamCampbell\Markdown\Facades\Markdown::class, 'ContextAwareValidator' => App\Facades\ContextAwareValidation::class, - 'Settings' => App\Facades\Options::class, + 'Settings' => App\Facades\Options::class ], diff --git a/config/auth.php b/config/auth.php index 071543c..aaf982b 100644 --- a/config/auth.php +++ b/config/auth.php @@ -1,24 +1,5 @@ . - */ - return [ /* diff --git a/config/broadcasting.php b/config/broadcasting.php index 2fa0dee..3bba110 100644 --- a/config/broadcasting.php +++ b/config/broadcasting.php @@ -1,24 +1,5 @@ . - */ - return [ /* diff --git a/config/cache.php b/config/cache.php index 475421a..4f41fdf 100644 --- a/config/cache.php +++ b/config/cache.php @@ -1,24 +1,5 @@ . - */ - use Illuminate\Support\Str; return [ diff --git a/config/cors.php b/config/cors.php index c06d99f..558369d 100644 --- a/config/cors.php +++ b/config/cors.php @@ -1,24 +1,5 @@ . - */ - return [ /* diff --git a/config/database.php b/config/database.php index 493e1af..b42d9b3 100644 --- a/config/database.php +++ b/config/database.php @@ -1,24 +1,5 @@ . - */ - use Illuminate\Support\Str; return [ diff --git a/config/filesystems.php b/config/filesystems.php index 7ae4a84..94c8112 100644 --- a/config/filesystems.php +++ b/config/filesystems.php @@ -1,24 +1,5 @@ . - */ - return [ /* diff --git a/config/general.php b/config/general.php index bdc5e90..7749c97 100644 --- a/config/general.php +++ b/config/general.php @@ -1,45 +1,27 @@ . - */ - return [ - 'urls' => [ + 'urls' => + [ 'mojang' => [ 'statuscheck' => env('MOJANG_STATUS_URL') ?? 'https://status.mojang.com/check', 'api' => env('MOJANG_API_URL') ?? ' https://api.mojang.com', - 'session' => env('MOJANG_SESSIONAPI_URL') ?? 'https://sessionserver.mojang.com', + 'session' => env('MOJANG_SESSIONAPI_URL') ?? 'https://sessionserver.mojang.com' ], 'ipapi' => [ - 'ipcheck' => env('IPGEO_API_URL') ?? 'https://api.ipgeolocation.io/ipgeo', - ], + 'ipcheck' => env('IPGEO_API_URL') ?? 'https://api.ipgeolocation.io/ipgeo' + ] ], 'keys' => [ 'ipapi' => [ - 'apikey' => env('IPGEO_API_KEY'), - ], + 'apikey' => env('IPGEO_API_KEY') + ] - ], + ] ]; diff --git a/config/google2fa.php b/config/google2fa.php index 42eab82..4dd5824 100644 --- a/config/google2fa.php +++ b/config/google2fa.php @@ -1,24 +1,5 @@ . - */ - return [ /* @@ -78,7 +59,7 @@ return [ * One Time Password error message. */ 'error_messages' => [ - 'wrong_otp' => 'Your one time code was incorrect.', + 'wrong_otp' => "Your one time code was incorrect.", 'cannot_be_empty' => 'The one time code cannot be empty.', 'unknown' => 'An unknown error has occurred. Please try again.', ], diff --git a/config/hashing.php b/config/hashing.php index e7a93bf..8425770 100644 --- a/config/hashing.php +++ b/config/hashing.php @@ -1,24 +1,5 @@ . - */ - return [ /* diff --git a/config/laravellocalization.php b/config/laravellocalization.php index 8055da2..37578d7 100644 --- a/config/laravellocalization.php +++ b/config/laravellocalization.php @@ -1,24 +1,5 @@ . - */ - return [ // Uncomment the languages that your site supports - or add new ones. @@ -83,7 +64,7 @@ return [ '/app.css', '/robots.txt', '/slides/*', - '/auth/logout', + '/auth/logout' ], ]; diff --git a/config/log-viewer.php b/config/log-viewer.php index c733cb7..b0532ba 100644 --- a/config/log-viewer.php +++ b/config/log-viewer.php @@ -1,24 +1,5 @@ . - */ - use Arcanedev\LogViewer\Contracts\Utilities\Filesystem; return [ @@ -114,7 +95,7 @@ return [ 'icons' => [ /** * Font awesome >= 4.3 - * http://fontawesome.io/icons/. + * http://fontawesome.io/icons/ */ 'all' => 'fa fa-fw fa-list', // http://fontawesome.io/icon/list/ 'emergency' => 'fa fa-fw fa-bug', // http://fontawesome.io/icon/bug/ diff --git a/config/logging.php b/config/logging.php index 283cdeb..088c204 100644 --- a/config/logging.php +++ b/config/logging.php @@ -1,24 +1,5 @@ . - */ - use Monolog\Handler\NullHandler; use Monolog\Handler\StreamHandler; use Monolog\Handler\SyslogUdpHandler; diff --git a/config/mail.php b/config/mail.php index bf9953d..5201bb7 100644 --- a/config/mail.php +++ b/config/mail.php @@ -1,24 +1,5 @@ . - */ - return [ /* diff --git a/config/markdown.php b/config/markdown.php index a206312..6408d6f 100644 --- a/config/markdown.php +++ b/config/markdown.php @@ -3,22 +3,12 @@ declare(strict_types=1); /* - * Copyright © 2020 Miguel Nogueira + * This file is part of Laravel Markdown. * - * This file is part of Raspberry Staff Manager. + * (c) Graham Campbell * - * 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 . + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. */ return [ diff --git a/config/notification.php b/config/notification.php index 4abedc4..8f3da66 100644 --- a/config/notification.php +++ b/config/notification.php @@ -1,31 +1,12 @@ . - */ - return [ - 'sender' => [ + 'sender' => [ - 'address' => 'teams@spacejewel-hosting.com', - 'name' => 'RaspberryNet Teams', + 'address' => 'teams@spacejewel-hosting.com', + 'name' => 'RaspberryNet Teams' - ], + ] ]; diff --git a/config/permission.php b/config/permission.php index 23d28d1..d4a7764 100644 --- a/config/permission.php +++ b/config/permission.php @@ -1,24 +1,5 @@ . - */ - return [ 'models' => [ diff --git a/config/queue.php b/config/queue.php index 1ca3b3a..00b76d6 100644 --- a/config/queue.php +++ b/config/queue.php @@ -1,24 +1,5 @@ . - */ - return [ /* diff --git a/config/recaptcha.php b/config/recaptcha.php index 3487b17..82e0813 100644 --- a/config/recaptcha.php +++ b/config/recaptcha.php @@ -1,33 +1,14 @@ . - */ - return [ 'keys' => [ 'sitekey' => env('RECAPTCHA_SITE_KEY'), - 'secret' => env('RECAPTCHA_PRIVATE_KEY'), + 'secret' => env('RECAPTCHA_PRIVATE_KEY') ], 'verify' => [ - 'apiurl' => env('RECAPTCHA_VERIFY_URL'), - ], + 'apiurl' => env('RECAPTCHA_VERIFY_URL') + ] ]; diff --git a/config/sentry.php b/config/sentry.php index f8e2b20..4d9ef4d 100644 --- a/config/sentry.php +++ b/config/sentry.php @@ -1,24 +1,5 @@ . - */ - return [ 'dsn' => env('SENTRY_LARAVEL_DSN', env('SENTRY_DSN')), diff --git a/config/services.php b/config/services.php index cbda757..2a1d616 100644 --- a/config/services.php +++ b/config/services.php @@ -1,24 +1,5 @@ . - */ - return [ /* diff --git a/config/session.php b/config/session.php index a5b0c90..37ae384 100644 --- a/config/session.php +++ b/config/session.php @@ -1,24 +1,5 @@ . - */ - use Illuminate\Support\Str; return [ diff --git a/config/slack.php b/config/slack.php index 02627e7..2651cc4 100644 --- a/config/slack.php +++ b/config/slack.php @@ -1,30 +1,12 @@ . - */ - return [ - 'webhook' => [ + 'webhook' => [ - 'integrationURL' => env('SLACK_INTEGRATION_WEBHOOK'), + 'integrationURL' => env('SLACK_INTEGRATION_WEBHOOK') + + ] - ], ]; diff --git a/config/view.php b/config/view.php index 44a66b9..22b8a18 100644 --- a/config/view.php +++ b/config/view.php @@ -1,24 +1,5 @@ . - */ - return [ /* diff --git a/database/factories/UserFactory.php b/database/factories/UserFactory.php index 451aae6..741edea 100644 --- a/database/factories/UserFactory.php +++ b/database/factories/UserFactory.php @@ -1,23 +1,6 @@ . - */ +/** @var \Illuminate\Database\Eloquent\Factory $factory */ use App\User; use Faker\Generator as Faker; diff --git a/database/migrations/2014_10_12_000000_create_users_table.php b/database/migrations/2014_10_12_000000_create_users_table.php index 2596a64..4ee8c3e 100644 --- a/database/migrations/2014_10_12_000000_create_users_table.php +++ b/database/migrations/2014_10_12_000000_create_users_table.php @@ -1,24 +1,5 @@ . - */ - use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; diff --git a/database/migrations/2014_10_12_100000_create_password_resets_table.php b/database/migrations/2014_10_12_100000_create_password_resets_table.php index 7715044..0ee0a36 100644 --- a/database/migrations/2014_10_12_100000_create_password_resets_table.php +++ b/database/migrations/2014_10_12_100000_create_password_resets_table.php @@ -1,24 +1,5 @@ . - */ - use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; diff --git a/database/migrations/2019_08_19_000000_create_failed_jobs_table.php b/database/migrations/2019_08_19_000000_create_failed_jobs_table.php index b348447..9bddee3 100644 --- a/database/migrations/2019_08_19_000000_create_failed_jobs_table.php +++ b/database/migrations/2019_08_19_000000_create_failed_jobs_table.php @@ -1,24 +1,5 @@ . - */ - use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; diff --git a/database/migrations/2020_04_29_022245_create_profiles_table.php b/database/migrations/2020_04_29_022245_create_profiles_table.php index bc21b71..b3ac735 100644 --- a/database/migrations/2020_04_29_022245_create_profiles_table.php +++ b/database/migrations/2020_04_29_022245_create_profiles_table.php @@ -1,24 +1,5 @@ . - */ - use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; @@ -38,7 +19,7 @@ class CreateProfilesTable extends Migration $table->text('profileAboutMe')->nullable(); $table->enum('avatarPreference', [ 'crafatar', // Mojang Profile - 'gravatar', // Email profile + 'gravatar' // Email profile ])->default('gravatar'); $table->text('socialLinks')->nullable(); $table->bigInteger('userID')->unsigned(); diff --git a/database/migrations/2020_04_29_022402_create_applications_table.php b/database/migrations/2020_04_29_022402_create_applications_table.php index 529e046..3074f8e 100644 --- a/database/migrations/2020_04_29_022402_create_applications_table.php +++ b/database/migrations/2020_04_29_022402_create_applications_table.php @@ -1,24 +1,5 @@ . - */ - use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; @@ -47,7 +28,7 @@ class CreateApplicationsTable extends Migration 'STAGE_INTERVIEW', 'STAGE_INTERVIEW_SCHEDULED', 'APPROVED', - 'DENIED', + 'DENIED' ])->default('STAGE_SUBMITTED'); $table->timestamps(); diff --git a/database/migrations/2020_04_29_022421_create_votes_table.php b/database/migrations/2020_04_29_022421_create_votes_table.php index 6164f56..9062e22 100644 --- a/database/migrations/2020_04_29_022421_create_votes_table.php +++ b/database/migrations/2020_04_29_022421_create_votes_table.php @@ -1,24 +1,5 @@ . - */ - use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; @@ -37,7 +18,7 @@ class CreateVotesTable extends Migration $table->bigInteger('userID')->unsigned(); $table->enum('allowedVoteType', [ 'VOTE_DENY', - 'VOTE_APPROVE', + 'VOTE_APPROVE' ]); $table->timestamps(); diff --git a/database/migrations/2020_04_29_022442_create_appointments_table.php b/database/migrations/2020_04_29_022442_create_appointments_table.php index 08d60f2..77cce6e 100644 --- a/database/migrations/2020_04_29_022442_create_appointments_table.php +++ b/database/migrations/2020_04_29_022442_create_appointments_table.php @@ -1,24 +1,5 @@ . - */ - use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; @@ -42,11 +23,11 @@ class CreateAppointmentsTable extends Migration 'DISCORD', 'SKYPE', 'MEET', - 'TEAMSPEAK', + 'TEAMSPEAK' ]); $table->enum('appointmentStatus', [ - 'SCHEDULED', - 'CONCLUDED', // TODO: Review whether this status is necessary + 'SCHEDULED', + 'CONCLUDED' // TODO: Review whether this status is necessary ])->default('SCHEDULED'); $table->boolean('userAccepted')->default(false); $table->longText('meetingNotes')->nullable(); diff --git a/database/migrations/2020_04_29_022541_create_forms_table.php b/database/migrations/2020_04_29_022541_create_forms_table.php index 32fbc27..610a6d7 100644 --- a/database/migrations/2020_04_29_022541_create_forms_table.php +++ b/database/migrations/2020_04_29_022541_create_forms_table.php @@ -1,24 +1,5 @@ . - */ - use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; @@ -38,7 +19,7 @@ class CreateFormsTable extends Migration $table->string('formStructure'); $table->enum('formStatus', [ 'ACTIVE', - 'SUSPENDED', + 'SUSPENDED' ]); $table->timestamps(); }); diff --git a/database/migrations/2020_04_29_022542_create_vacancies_table.php b/database/migrations/2020_04_29_022542_create_vacancies_table.php index 7f17357..dfa3aa0 100644 --- a/database/migrations/2020_04_29_022542_create_vacancies_table.php +++ b/database/migrations/2020_04_29_022542_create_vacancies_table.php @@ -1,24 +1,5 @@ . - */ - use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; @@ -45,6 +26,7 @@ class CreateVacanciesTable extends Migration $table->foreign('vacancyFormID') ->references('id') ->on('forms'); + }); } diff --git a/database/migrations/2020_04_29_023647_create_staff_profiles_table.php b/database/migrations/2020_04_29_023647_create_staff_profiles_table.php index be2ba85..352dbca 100644 --- a/database/migrations/2020_04_29_023647_create_staff_profiles_table.php +++ b/database/migrations/2020_04_29_023647_create_staff_profiles_table.php @@ -1,24 +1,5 @@ . - */ - use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; diff --git a/database/migrations/2020_04_29_030107_create_responses_table.php b/database/migrations/2020_04_29_030107_create_responses_table.php index 02acc46..35ea926 100644 --- a/database/migrations/2020_04_29_030107_create_responses_table.php +++ b/database/migrations/2020_04_29_030107_create_responses_table.php @@ -1,24 +1,5 @@ . - */ - use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; @@ -42,6 +23,7 @@ class CreateResponsesTable extends Migration $table->foreign('responseFormID') ->references('id') ->on('forms'); + }); } diff --git a/database/migrations/2020_04_29_195848_votes_has_application.php b/database/migrations/2020_04_29_195848_votes_has_application.php index 8ccf13f..4464737 100644 --- a/database/migrations/2020_04_29_195848_votes_has_application.php +++ b/database/migrations/2020_04_29_195848_votes_has_application.php @@ -1,24 +1,5 @@ . - */ - use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; @@ -32,7 +13,8 @@ class VotesHasApplication extends Migration */ public function up() { - Schema::create('votes_has_application', function (Blueprint $table) { + Schema::create('votes_has_application', function (Blueprint $table){ + $table->id('id'); $table->bigInteger('vote_id')->unsigned(); $table->bigInteger('application_id')->unsigned(); @@ -40,6 +22,7 @@ class VotesHasApplication extends Migration $table->foreign('vote_id')->references('id')->on('votes'); $table->foreign('application_id')->references('id')->on('applications'); + }); } diff --git a/database/migrations/2020_05_02_223355_create_cache_table.php b/database/migrations/2020_05_02_223355_create_cache_table.php index f50d132..7b73e5f 100644 --- a/database/migrations/2020_05_02_223355_create_cache_table.php +++ b/database/migrations/2020_05_02_223355_create_cache_table.php @@ -1,24 +1,5 @@ . - */ - use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; diff --git a/database/migrations/2020_05_07_021604_add_status_to_vacancies.php b/database/migrations/2020_05_07_021604_add_status_to_vacancies.php index 830bec4..1d40c92 100644 --- a/database/migrations/2020_05_07_021604_add_status_to_vacancies.php +++ b/database/migrations/2020_05_07_021604_add_status_to_vacancies.php @@ -1,24 +1,5 @@ . - */ - use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; @@ -35,7 +16,7 @@ class AddStatusToVacancies extends Migration Schema::table('vacancies', function (Blueprint $table) { $table->enum('vacancyStatus', [ 'OPEN', - 'CLOSED', + 'CLOSED' ])->after('vacancyCount'); }); } diff --git a/database/migrations/2020_05_08_024654_add_slug_to_vacancy.php b/database/migrations/2020_05_08_024654_add_slug_to_vacancy.php index e14f42e..5daa2c6 100644 --- a/database/migrations/2020_05_08_024654_add_slug_to_vacancy.php +++ b/database/migrations/2020_05_08_024654_add_slug_to_vacancy.php @@ -1,24 +1,5 @@ . - */ - use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; diff --git a/database/migrations/2020_05_08_063141_add_vacancy_i_d_to_responses.php b/database/migrations/2020_05_08_063141_add_vacancy_i_d_to_responses.php index f2a3ea4..e8b8591 100644 --- a/database/migrations/2020_05_08_063141_add_vacancy_i_d_to_responses.php +++ b/database/migrations/2020_05_08_063141_add_vacancy_i_d_to_responses.php @@ -1,24 +1,5 @@ . - */ - use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; diff --git a/database/migrations/2020_05_14_004542_change_form_structure_length.php b/database/migrations/2020_05_14_004542_change_form_structure_length.php index eb699ca..9ba0006 100644 --- a/database/migrations/2020_05_14_004542_change_form_structure_length.php +++ b/database/migrations/2020_05_14_004542_change_form_structure_length.php @@ -1,24 +1,5 @@ . - */ - use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; @@ -32,8 +13,8 @@ class ChangeFormStructureLength extends Migration */ public function up() { - Schema::table('forms', function (Blueprint $schema) { - $schema->longText('formStructure')->change(); + Schema::table('forms', function (Blueprint $schema){ + $schema->longText('formStructure')->change(); }); } diff --git a/database/migrations/2020_05_29_234431_create_permission_tables.php b/database/migrations/2020_05_29_234431_create_permission_tables.php index e790941..3f9448d 100644 --- a/database/migrations/2020_05_29_234431_create_permission_tables.php +++ b/database/migrations/2020_05_29_234431_create_permission_tables.php @@ -1,27 +1,8 @@ . - */ - -use Illuminate\Database\Migrations\Migration; -use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; +use Illuminate\Database\Schema\Blueprint; +use Illuminate\Database\Migrations\Migration; class CreatePermissionTables extends Migration { diff --git a/database/migrations/2020_06_08_153602_create_bans_table.php b/database/migrations/2020_06_08_153602_create_bans_table.php index dd18593..7674c17 100644 --- a/database/migrations/2020_06_08_153602_create_bans_table.php +++ b/database/migrations/2020_06_08_153602_create_bans_table.php @@ -1,24 +1,5 @@ . - */ - use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; @@ -44,6 +25,7 @@ class CreateBansTable extends Migration $table->foreign('userID') ->references('id') ->on('users'); + }); } diff --git a/database/migrations/2020_06_20_210255_create_comments_table.php b/database/migrations/2020_06_20_210255_create_comments_table.php index fc9c1d2..501254f 100644 --- a/database/migrations/2020_06_20_210255_create_comments_table.php +++ b/database/migrations/2020_06_20_210255_create_comments_table.php @@ -1,24 +1,5 @@ . - */ - use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; @@ -47,6 +28,8 @@ class CreateCommentsTable extends Migration ->references('id') ->on('applications'); }); + + } /** diff --git a/database/migrations/2020_06_25_093708_create_jobs_table.php b/database/migrations/2020_06_25_093708_create_jobs_table.php index 55d71dd..1be9e8a 100644 --- a/database/migrations/2020_06_25_093708_create_jobs_table.php +++ b/database/migrations/2020_06_25_093708_create_jobs_table.php @@ -1,24 +1,5 @@ . - */ - use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; diff --git a/database/migrations/2020_07_11_020743_add_detailed_description_to_vacancy.php b/database/migrations/2020_07_11_020743_add_detailed_description_to_vacancy.php index e443101..d049d3f 100644 --- a/database/migrations/2020_07_11_020743_add_detailed_description_to_vacancy.php +++ b/database/migrations/2020_07_11_020743_add_detailed_description_to_vacancy.php @@ -1,24 +1,5 @@ . - */ - use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; diff --git a/database/migrations/2020_07_17_053247_add_twofa_secret_to_users.php b/database/migrations/2020_07_17_053247_add_twofa_secret_to_users.php index 5ebf83d..b4dd0a9 100644 --- a/database/migrations/2020_07_17_053247_add_twofa_secret_to_users.php +++ b/database/migrations/2020_07_17_053247_add_twofa_secret_to_users.php @@ -1,24 +1,5 @@ . - */ - use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; diff --git a/database/migrations/2020_08_30_152900_create_options_table.php b/database/migrations/2020_08_30_152900_create_options_table.php index 570a08f..2c0537c 100644 --- a/database/migrations/2020_08_30_152900_create_options_table.php +++ b/database/migrations/2020_08_30_152900_create_options_table.php @@ -1,24 +1,5 @@ . - */ - use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; diff --git a/database/seeds/DatabaseSeeder.php b/database/seeds/DatabaseSeeder.php index 2c6e2f1..0db89f7 100644 --- a/database/seeds/DatabaseSeeder.php +++ b/database/seeds/DatabaseSeeder.php @@ -1,24 +1,5 @@ . - */ - use Illuminate\Database\Seeder; class DatabaseSeeder extends Seeder diff --git a/database/seeds/DefaultOptionsSeeder.php b/database/seeds/DefaultOptionsSeeder.php index 34811fc..90e73c5 100644 --- a/database/seeds/DefaultOptionsSeeder.php +++ b/database/seeds/DefaultOptionsSeeder.php @@ -1,24 +1,5 @@ . - */ - use App\Facades\Options; use Illuminate\Database\Seeder; @@ -38,7 +19,9 @@ class DefaultOptionsSeeder extends Seeder Options::setOption('notify_applicant_approved', true, 'Notify when an applicant is approved'); // done Options::setOption('notify_vacancystatus_change', false, 'Notify when a vacancy\'s status changes'); // done + Options::setOption('enable_slack_notifications', true, 'Enable slack notifications'); Options::setOption('enable_email_notifications', true, 'Enable e-mail notifications'); + } } diff --git a/database/seeds/NewPermissions.php b/database/seeds/NewPermissions.php index 8d3dc85..cc8b484 100644 --- a/database/seeds/NewPermissions.php +++ b/database/seeds/NewPermissions.php @@ -1,24 +1,5 @@ . - */ - use Illuminate\Database\Seeder; use Spatie\Permission\Models\Permission; use Spatie\Permission\Models\Role; @@ -33,7 +14,7 @@ class NewPermissions extends Seeder public function run() { $developer = Role::create([ - 'name' => 'developer', + 'name' => 'developer' ]); $admin = Role::where('name', 'admin')->first(); @@ -44,5 +25,7 @@ class NewPermissions extends Seeder $developer->givePermissionTo('admin.developertools.use'); $admin->givePermissionTo('admin.settings.view'); $admin->givePermissionTo('admin.settings.edit'); + + } } diff --git a/database/seeds/PermissionSeeder.php b/database/seeds/PermissionSeeder.php index 66694a1..2fde5f4 100644 --- a/database/seeds/PermissionSeeder.php +++ b/database/seeds/PermissionSeeder.php @@ -1,24 +1,5 @@ . - */ - use Illuminate\Database\Seeder; use Spatie\Permission\Models\Permission; use Spatie\Permission\Models\Role; @@ -37,24 +18,24 @@ class PermissionSeeder extends Seeder // $user = Role::create( [ - 'name' => 'user', + 'name' => 'user' ] ); $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) @@ -86,18 +67,19 @@ class PermissionSeeder extends Seeder Permission::create(['name' => 'admin.notificationsettings.*']); Permission::create(['name' => 'admin.maintenance.logs.view']); + Permission::create(['name' => 'admin.developertools.use']); $user->givePermissionTo([ 'applications.submit', 'applications.view.own', - 'profiles.view.others', + 'profiles.view.others' ]); // 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('appointments.*', 'applications.*', 'admin.hiring.*'); @@ -110,7 +92,7 @@ class PermissionSeeder extends Seeder 'admin.notificationsettings.*', 'profiles.view.others', 'profiles.edit.others', - 'admin.maintenance.logs.view', + 'admin.maintenance.logs.view' ]); } } diff --git a/database/seeds/UserSeeder.php b/database/seeds/UserSeeder.php index 0f2f838..8ba2603 100644 --- a/database/seeds/UserSeeder.php +++ b/database/seeds/UserSeeder.php @@ -1,24 +1,5 @@ . - */ - use App\Profile; use App\User; use Illuminate\Database\Seeder; @@ -41,7 +22,7 @@ class UserSeeder extends Seeder 'email' => 'tester1@example.com', 'username' => 'tester1', 'originalIP' => '99.18.146.235', - 'password' => Hash::make('password'), + 'password' => Hash::make('password') ], [ 'uuid' => 'ab22b5da02644953ace969fce85c0819', @@ -49,7 +30,7 @@ class UserSeeder extends Seeder 'email' => 'tester2@example.com', 'username' => 'tester2', 'originalIP' => '141.239.229.53', - 'password' => Hash::make('password'), + 'password' => Hash::make('password') ], [ 'uuid' => 'df38e6bf762944d3a600ded59a693ad1', @@ -57,7 +38,7 @@ class UserSeeder extends Seeder 'email' => 'tester3@example.com', 'username' => 'tester3', 'originalIP' => '25.63.20.97', - 'password' => Hash::make('password'), + 'password' => Hash::make('password') ], [ 'uuid' => '689e446484824f6bad5064e3df0aaa96', @@ -65,7 +46,7 @@ class UserSeeder extends Seeder 'email' => 'tester4@example.com', 'username' => 'tester4', 'originalIP' => '220.105.223.142', - 'password' => Hash::make('password'), + 'password' => Hash::make('password') ], [ 'uuid' => '172391f917bf418ab1c40ebc041ed5ba', @@ -73,7 +54,7 @@ class UserSeeder extends Seeder 'email' => 'tester5@example.com', 'username' => 'tester5', 'originalIP' => '224.66.76.60', - 'password' => Hash::make('password'), + 'password' => Hash::make('password') ], [ 'uuid' => '371f34dcce2a4457bf385ab9417a2345', @@ -81,7 +62,7 @@ class UserSeeder extends Seeder 'email' => 'tester6@example.com', 'username' => 'tester6', 'originalIP' => '97.113.131.0', - 'password' => Hash::make('password'), + 'password' => Hash::make('password') ], [ 'uuid' => '89aa5222855542bebe7a7780248ef5f9', @@ -89,7 +70,7 @@ class UserSeeder extends Seeder 'email' => 'tester7@example.com', 'username' => 'tester7', 'originalIP' => '15.160.137.222', - 'password' => Hash::make('password'), + 'password' => Hash::make('password') ], ]; @@ -102,7 +83,7 @@ class UserSeeder extends Seeder 'email' => 'user1@example.com', 'username' => 'user1', 'originalIP' => '253.25.237.78', - 'password' => Hash::make('password'), + 'password' => Hash::make('password') ], [ 'uuid' => '5f900018241e4aaba7883f2d5c5c2357', @@ -110,7 +91,7 @@ class UserSeeder extends Seeder 'email' => 'user2@example.com', 'username' => 'user2', 'originalIP' => '82.92.156.176', - 'password' => Hash::make('password'), + 'password' => Hash::make('password') ], [ 'uuid' => 'ba9780c3270745c6840eaabe1bf8aa14', @@ -118,31 +99,34 @@ class UserSeeder extends Seeder 'email' => 'user3@example.com', 'username' => 'user3', 'originalIP' => '224.123.129.17', - 'password' => Hash::make('password'), - ], + 'password' => Hash::make('password') + ] ]; - foreach ($regularUsers as $regularUser) { + foreach ($regularUsers as $regularUser) + { $user = User::create($regularUser); Profile::create([ - 'profileShortBio' => 'Random data '.rand(0, 1000), - 'profileAboutMe' => 'Random data '.rand(0, 1000), - 'socialLinks' => '[]', // empty json set, not an array + 'profileShortBio' => 'Random data ' . rand(0,1000), + 'profileAboutMe' => 'Random data ' . rand(0, 1000), + 'socialLinks' => "[]", // empty json set, not an array 'avatarPreference' => 'gravatar', - 'userID' => $user->id, + 'userID' => $user->id ]); } - foreach ($staffUsers as $staffUser) { + foreach($staffUsers as $staffUser) + { $user = User::create($staffUser); Profile::create([ - 'profileShortBio' => 'Random data '.rand(0, 1000), - 'profileAboutMe' => 'Random data '.rand(0, 1000), - 'socialLinks' => '[]', + 'profileShortBio' => 'Random data ' . rand(0,1000), + 'profileAboutMe' => 'Random data ' . rand(0, 1000), + 'socialLinks' => "[]", 'avatarPreference' => 'gravatar', - 'userID' => $user->id, + 'userID' => $user->id ]); + } User::create([ @@ -151,10 +135,11 @@ class UserSeeder extends Seeder 'email' => 'admin@example.com', 'username' => 'admin', 'originalIP' => '192.168.1.2', - 'password' => Hash::make('password'), + 'password' => Hash::make('password') ]); - foreach (User::all() as $user) { + foreach (User::all() as $user) + { $user->assignRole('reviewer', 'user'); } } diff --git a/public/index.php b/public/index.php index e71fcb9..4584cbc 100644 --- a/public/index.php +++ b/public/index.php @@ -1,22 +1,10 @@ . + * @package Laravel + * @author Taylor Otwell */ define('LARAVEL_START', microtime(true)); diff --git a/resources/lang/en/auth.php b/resources/lang/en/auth.php index f7c5c88..e5506df 100644 --- a/resources/lang/en/auth.php +++ b/resources/lang/en/auth.php @@ -1,24 +1,5 @@ . - */ - return [ /* diff --git a/resources/lang/en/messages.php b/resources/lang/en/messages.php index cb43ba7..9be7687 100644 --- a/resources/lang/en/messages.php +++ b/resources/lang/en/messages.php @@ -1,28 +1,24 @@ 'translate-me' + * Also, don't translate, change, or move placeholders (:this-is-a-placeholder) starting with a colon. + * Try to keep the message as close to the original in meaning as possible. These simple rules also apply to other files you're translating, such as: + * auth.php, pagination.php, passwords.php, and validation.php. + * It is VERY important that you "escape" single quotes with a backslash if they're present in your language, like this: I\'m an escaped quote * - * This file is part of Raspberry Staff Manager. + * Additionally, don't change anything in square or curly brackets, and don't remove pipe (|) characters. + * If you see two messages separated by pipe, then usually the left side is singular and the right side is plural, so translate accordingly. * - * 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 . + * Thank you for translating! */ return [ // ============== MENU TRANSLATIONS ====================== + 'menu' => [ 'my_apps' => 'My Applications', @@ -32,9 +28,11 @@ return [ 'all_forms' => 'All Forms', 'app_settings' => 'App Settings', 'global_app_settings' => 'Global App Settings', - 'system_logs' => 'System Logs', + 'system_logs' => 'System Logs' ], + + // ============== REUSABLE, GENERIC STRINGS =============== 'reusable' => [ @@ -81,9 +79,10 @@ return [ 'platform' => 'Platform', 'notepad' => 'Shared Notepad', // Context: The shared notepad that appears when votes are needed, 'appointment_info' => 'Appointment Information', - 'ip_info' => 'IP Address Information for', + 'ip_info' => 'IP Address Information for' ], + // ============== HOMEPAGE MESSAGES ====================== 'home' => 'Home', @@ -126,6 +125,8 @@ return [ 'contactlabel_subject' => 'Subject (ex. Site Suggestion)', 'contactlabel_send' => 'Send', + + // ======================== AUTHENTICATION MESSAGES =========================== '2fa_txt' => 'Two-Factor Authentication', @@ -150,7 +151,7 @@ return [ 'line4' => 'A minimum of 10 characters;', 'line5' => 'At least 3 uppercase characters;', 'line6' => 'At least 3 numbers;', - 'line7' => 'Any number of special characters.', + 'line7' => 'Any number of special characters.' ], 'sronly_confirmpassword' => 'Confirm Password', // hint: sronly stands for screen-reader only 'sronly_mcusername' => 'Minecraft Username (Premium)', @@ -179,6 +180,7 @@ return [ 'upcoming' => 'Your upcoming interviews', 'soon' => 'Coming soon', + //=================== ADMINISTRATION MESSAGES (for all administration pages) =============== 'adm' => 'Administration', @@ -196,6 +198,7 @@ return [ 'artisan_evaluate' => 'Artisan: Evaluate Votes Now', // Tip: Artisan is a program name, therefore not translatable 'devtools_info' => 'This panel may be also used to completely override the vote system in stalemate scenarios', + 'forms' => 'Forms', 'positions' => 'Positions', // Context: Positions as in job opening 'edit_form' => 'Edit Form', @@ -231,7 +234,7 @@ return [ 'cancel' => 'Cancel', 'close_vacancy' => 'Close Position', 'description_tooltip' => 'Add things like admission requirements, rank resposibilities and roles, and anything else you feel is necessary', - '', + '' ], @@ -249,7 +252,7 @@ return [ 'title' => 'Application Form Preview', 'looks' => 'This is how your form looks like to applicants', 'f_info' => 'You may edit it and add more fields later.', - '', + '' ], 'forms_p' => [ @@ -257,7 +260,7 @@ return [ 'available_forms' => 'Available forms', 'form_title' => 'Form title', 'empty_noforms' => 'Nothing to see here! Please add some forms first.', - 'new_form' => 'NEW FORM', + 'new_form' => 'NEW FORM' ], 'players' => [ @@ -278,7 +281,7 @@ return [ Registered players are those without a staff role in the team management application. There may be other users registered in the platform, but they won't be displayed here. ", - 'see_staff' => 'See Staff Members', + 'see_staff' => 'See Staff Members' ], @@ -302,7 +305,7 @@ return [ 'settings' => 'Settings', 'settings_header' => 'Notification Settings', 'settings_p' => 'Change which notifications are sent here.', - 'back_btn' => 'Back to Dashboard', + 'back_btn' => 'Back to Dashboard' ], @@ -328,17 +331,19 @@ return [ 'yrs_old' => 'Years old', // Context: "years old" as in: Tom is 24 years old 'line1' => 'We\'re glad you\'ve decided to apply. Generally, applications take 48 hours to be processed and reviewed. Depending on the circumstances and the volume of applications, you may receive an answer in a shorter time.', 'line2' => 'Please fill out the form below. Keep all answers concise and complete. Please keep in mind that the age requirement is at least :agerqr.', - 'line3' => 'Asking about your application will result in instant denial. Everything you need to know is here.', + 'line3' => 'Asking about your application will result in instant denial. Everything you need to know is here.' ], - 'app_timeout' => 'Your account is not permitted to submit another application. Please wait :days more days before trying to submit an application.', + 'app_timeout' => 'Your account is not permitted to submit another application. Please wait :days more days before trying to submit an application.' ], + 'application_m' => [ 'title' => 'Application Management', 'all_apps' => 'All Applications', 'modal_confirm' => 'Are you sure?', 'really_delete' => 'Really delete this?', + 'outstanding_sm' => 'Outstanding', 'outstanding_apps' => 'Outstanding Applications', 'outstanding_subm' => 'Outstanding (Submitted)', @@ -395,7 +400,7 @@ return [ 'title' => 'Voting Reminder', 'line1' => 'Applications which gain more than 50% of positive votes are automatically approved after one day.', 'line2' => 'Conversely, applications that do not reach this number are automatically denied.', - 'line3' => 'Please note that the vote system can be overridden', + 'line3' => 'Please note that the vote system can be overridden' ], @@ -516,7 +521,7 @@ return [ 'insta_user' => 'Instagram Username', 'discord_user' => 'Discord Handle', - 'update_prfl' => 'Update Profile', + 'update_prfl' => 'Update Profile' ], @@ -527,7 +532,7 @@ return [ 'app_process' => [ 'title' => 'Application Process', 'line1' => 'Please allow up to three days for your application to be processed. Your application will be reviewed by every team member, and will move up in stages.', - 'line2' => 'If an interview is scheduled, you\'ll need to open your application here and confirm the time, date, and location assigned for you.', + 'line2' => 'If an interview is scheduled, you\'ll need to open your application here and confirm the time, date, and location assigned for you.' ], 'account_standing' => 'Account Standing', @@ -546,9 +551,9 @@ return [ 'itsyou' => 'It\'s you!', 'title' => 'User Directory', - 'directory' => 'Directory', + 'directory' => 'Directory' - ], + ] ], @@ -585,7 +590,7 @@ return [ 'line1' => 'If you weren\'t present during this meeting, you can view the shared meeting notepad to help you make a decision.', 'line2' => 'You may vote on as many applications as needed; However, you can only vote once per application.', - 'line3' => 'Votes carry no weight based on rank. This system has been designed with fairness and ease of use in mind.', + 'line3' => 'Votes carry no weight based on rank. This system has been designed with fairness and ease of use in mind.' ], @@ -600,7 +605,7 @@ return [ 'max_chars' => 'max characters', // Context: A number is added before max characters 'post' => 'Post', // Context: Post as in post comment - ], + ] // ==================== END OF MAIN I18N FILE ====================== diff --git a/resources/lang/en/pagination.php b/resources/lang/en/pagination.php index 59d8a5d..d481411 100644 --- a/resources/lang/en/pagination.php +++ b/resources/lang/en/pagination.php @@ -1,24 +1,5 @@ . - */ - return [ /* diff --git a/resources/lang/en/passwords.php b/resources/lang/en/passwords.php index 8957598..2345a56 100644 --- a/resources/lang/en/passwords.php +++ b/resources/lang/en/passwords.php @@ -1,24 +1,5 @@ . - */ - return [ /* diff --git a/resources/lang/en/validation.php b/resources/lang/en/validation.php index b5f1b29..a65914f 100644 --- a/resources/lang/en/validation.php +++ b/resources/lang/en/validation.php @@ -1,24 +1,5 @@ . - */ - return [ /* diff --git a/resources/lang/es/auth.php b/resources/lang/es/auth.php index f7c5c88..e5506df 100644 --- a/resources/lang/es/auth.php +++ b/resources/lang/es/auth.php @@ -1,24 +1,5 @@ . - */ - return [ /* diff --git a/resources/lang/es/messages.php b/resources/lang/es/messages.php index cb43ba7..9be7687 100644 --- a/resources/lang/es/messages.php +++ b/resources/lang/es/messages.php @@ -1,28 +1,24 @@ 'translate-me' + * Also, don't translate, change, or move placeholders (:this-is-a-placeholder) starting with a colon. + * Try to keep the message as close to the original in meaning as possible. These simple rules also apply to other files you're translating, such as: + * auth.php, pagination.php, passwords.php, and validation.php. + * It is VERY important that you "escape" single quotes with a backslash if they're present in your language, like this: I\'m an escaped quote * - * This file is part of Raspberry Staff Manager. + * Additionally, don't change anything in square or curly brackets, and don't remove pipe (|) characters. + * If you see two messages separated by pipe, then usually the left side is singular and the right side is plural, so translate accordingly. * - * 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 . + * Thank you for translating! */ return [ // ============== MENU TRANSLATIONS ====================== + 'menu' => [ 'my_apps' => 'My Applications', @@ -32,9 +28,11 @@ return [ 'all_forms' => 'All Forms', 'app_settings' => 'App Settings', 'global_app_settings' => 'Global App Settings', - 'system_logs' => 'System Logs', + 'system_logs' => 'System Logs' ], + + // ============== REUSABLE, GENERIC STRINGS =============== 'reusable' => [ @@ -81,9 +79,10 @@ return [ 'platform' => 'Platform', 'notepad' => 'Shared Notepad', // Context: The shared notepad that appears when votes are needed, 'appointment_info' => 'Appointment Information', - 'ip_info' => 'IP Address Information for', + 'ip_info' => 'IP Address Information for' ], + // ============== HOMEPAGE MESSAGES ====================== 'home' => 'Home', @@ -126,6 +125,8 @@ return [ 'contactlabel_subject' => 'Subject (ex. Site Suggestion)', 'contactlabel_send' => 'Send', + + // ======================== AUTHENTICATION MESSAGES =========================== '2fa_txt' => 'Two-Factor Authentication', @@ -150,7 +151,7 @@ return [ 'line4' => 'A minimum of 10 characters;', 'line5' => 'At least 3 uppercase characters;', 'line6' => 'At least 3 numbers;', - 'line7' => 'Any number of special characters.', + 'line7' => 'Any number of special characters.' ], 'sronly_confirmpassword' => 'Confirm Password', // hint: sronly stands for screen-reader only 'sronly_mcusername' => 'Minecraft Username (Premium)', @@ -179,6 +180,7 @@ return [ 'upcoming' => 'Your upcoming interviews', 'soon' => 'Coming soon', + //=================== ADMINISTRATION MESSAGES (for all administration pages) =============== 'adm' => 'Administration', @@ -196,6 +198,7 @@ return [ 'artisan_evaluate' => 'Artisan: Evaluate Votes Now', // Tip: Artisan is a program name, therefore not translatable 'devtools_info' => 'This panel may be also used to completely override the vote system in stalemate scenarios', + 'forms' => 'Forms', 'positions' => 'Positions', // Context: Positions as in job opening 'edit_form' => 'Edit Form', @@ -231,7 +234,7 @@ return [ 'cancel' => 'Cancel', 'close_vacancy' => 'Close Position', 'description_tooltip' => 'Add things like admission requirements, rank resposibilities and roles, and anything else you feel is necessary', - '', + '' ], @@ -249,7 +252,7 @@ return [ 'title' => 'Application Form Preview', 'looks' => 'This is how your form looks like to applicants', 'f_info' => 'You may edit it and add more fields later.', - '', + '' ], 'forms_p' => [ @@ -257,7 +260,7 @@ return [ 'available_forms' => 'Available forms', 'form_title' => 'Form title', 'empty_noforms' => 'Nothing to see here! Please add some forms first.', - 'new_form' => 'NEW FORM', + 'new_form' => 'NEW FORM' ], 'players' => [ @@ -278,7 +281,7 @@ return [ Registered players are those without a staff role in the team management application. There may be other users registered in the platform, but they won't be displayed here. ", - 'see_staff' => 'See Staff Members', + 'see_staff' => 'See Staff Members' ], @@ -302,7 +305,7 @@ return [ 'settings' => 'Settings', 'settings_header' => 'Notification Settings', 'settings_p' => 'Change which notifications are sent here.', - 'back_btn' => 'Back to Dashboard', + 'back_btn' => 'Back to Dashboard' ], @@ -328,17 +331,19 @@ return [ 'yrs_old' => 'Years old', // Context: "years old" as in: Tom is 24 years old 'line1' => 'We\'re glad you\'ve decided to apply. Generally, applications take 48 hours to be processed and reviewed. Depending on the circumstances and the volume of applications, you may receive an answer in a shorter time.', 'line2' => 'Please fill out the form below. Keep all answers concise and complete. Please keep in mind that the age requirement is at least :agerqr.', - 'line3' => 'Asking about your application will result in instant denial. Everything you need to know is here.', + 'line3' => 'Asking about your application will result in instant denial. Everything you need to know is here.' ], - 'app_timeout' => 'Your account is not permitted to submit another application. Please wait :days more days before trying to submit an application.', + 'app_timeout' => 'Your account is not permitted to submit another application. Please wait :days more days before trying to submit an application.' ], + 'application_m' => [ 'title' => 'Application Management', 'all_apps' => 'All Applications', 'modal_confirm' => 'Are you sure?', 'really_delete' => 'Really delete this?', + 'outstanding_sm' => 'Outstanding', 'outstanding_apps' => 'Outstanding Applications', 'outstanding_subm' => 'Outstanding (Submitted)', @@ -395,7 +400,7 @@ return [ 'title' => 'Voting Reminder', 'line1' => 'Applications which gain more than 50% of positive votes are automatically approved after one day.', 'line2' => 'Conversely, applications that do not reach this number are automatically denied.', - 'line3' => 'Please note that the vote system can be overridden', + 'line3' => 'Please note that the vote system can be overridden' ], @@ -516,7 +521,7 @@ return [ 'insta_user' => 'Instagram Username', 'discord_user' => 'Discord Handle', - 'update_prfl' => 'Update Profile', + 'update_prfl' => 'Update Profile' ], @@ -527,7 +532,7 @@ return [ 'app_process' => [ 'title' => 'Application Process', 'line1' => 'Please allow up to three days for your application to be processed. Your application will be reviewed by every team member, and will move up in stages.', - 'line2' => 'If an interview is scheduled, you\'ll need to open your application here and confirm the time, date, and location assigned for you.', + 'line2' => 'If an interview is scheduled, you\'ll need to open your application here and confirm the time, date, and location assigned for you.' ], 'account_standing' => 'Account Standing', @@ -546,9 +551,9 @@ return [ 'itsyou' => 'It\'s you!', 'title' => 'User Directory', - 'directory' => 'Directory', + 'directory' => 'Directory' - ], + ] ], @@ -585,7 +590,7 @@ return [ 'line1' => 'If you weren\'t present during this meeting, you can view the shared meeting notepad to help you make a decision.', 'line2' => 'You may vote on as many applications as needed; However, you can only vote once per application.', - 'line3' => 'Votes carry no weight based on rank. This system has been designed with fairness and ease of use in mind.', + 'line3' => 'Votes carry no weight based on rank. This system has been designed with fairness and ease of use in mind.' ], @@ -600,7 +605,7 @@ return [ 'max_chars' => 'max characters', // Context: A number is added before max characters 'post' => 'Post', // Context: Post as in post comment - ], + ] // ==================== END OF MAIN I18N FILE ====================== diff --git a/resources/lang/es/pagination.php b/resources/lang/es/pagination.php index 59d8a5d..d481411 100644 --- a/resources/lang/es/pagination.php +++ b/resources/lang/es/pagination.php @@ -1,24 +1,5 @@ . - */ - return [ /* diff --git a/resources/lang/es/passwords.php b/resources/lang/es/passwords.php index 8957598..2345a56 100644 --- a/resources/lang/es/passwords.php +++ b/resources/lang/es/passwords.php @@ -1,24 +1,5 @@ . - */ - return [ /* diff --git a/resources/lang/es/validation.php b/resources/lang/es/validation.php index b5f1b29..a65914f 100644 --- a/resources/lang/es/validation.php +++ b/resources/lang/es/validation.php @@ -1,24 +1,5 @@ . - */ - return [ /* diff --git a/resources/lang/fr/auth.php b/resources/lang/fr/auth.php index f7c5c88..e5506df 100644 --- a/resources/lang/fr/auth.php +++ b/resources/lang/fr/auth.php @@ -1,24 +1,5 @@ . - */ - return [ /* diff --git a/resources/lang/fr/messages.php b/resources/lang/fr/messages.php index cb43ba7..9be7687 100644 --- a/resources/lang/fr/messages.php +++ b/resources/lang/fr/messages.php @@ -1,28 +1,24 @@ 'translate-me' + * Also, don't translate, change, or move placeholders (:this-is-a-placeholder) starting with a colon. + * Try to keep the message as close to the original in meaning as possible. These simple rules also apply to other files you're translating, such as: + * auth.php, pagination.php, passwords.php, and validation.php. + * It is VERY important that you "escape" single quotes with a backslash if they're present in your language, like this: I\'m an escaped quote * - * This file is part of Raspberry Staff Manager. + * Additionally, don't change anything in square or curly brackets, and don't remove pipe (|) characters. + * If you see two messages separated by pipe, then usually the left side is singular and the right side is plural, so translate accordingly. * - * 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 . + * Thank you for translating! */ return [ // ============== MENU TRANSLATIONS ====================== + 'menu' => [ 'my_apps' => 'My Applications', @@ -32,9 +28,11 @@ return [ 'all_forms' => 'All Forms', 'app_settings' => 'App Settings', 'global_app_settings' => 'Global App Settings', - 'system_logs' => 'System Logs', + 'system_logs' => 'System Logs' ], + + // ============== REUSABLE, GENERIC STRINGS =============== 'reusable' => [ @@ -81,9 +79,10 @@ return [ 'platform' => 'Platform', 'notepad' => 'Shared Notepad', // Context: The shared notepad that appears when votes are needed, 'appointment_info' => 'Appointment Information', - 'ip_info' => 'IP Address Information for', + 'ip_info' => 'IP Address Information for' ], + // ============== HOMEPAGE MESSAGES ====================== 'home' => 'Home', @@ -126,6 +125,8 @@ return [ 'contactlabel_subject' => 'Subject (ex. Site Suggestion)', 'contactlabel_send' => 'Send', + + // ======================== AUTHENTICATION MESSAGES =========================== '2fa_txt' => 'Two-Factor Authentication', @@ -150,7 +151,7 @@ return [ 'line4' => 'A minimum of 10 characters;', 'line5' => 'At least 3 uppercase characters;', 'line6' => 'At least 3 numbers;', - 'line7' => 'Any number of special characters.', + 'line7' => 'Any number of special characters.' ], 'sronly_confirmpassword' => 'Confirm Password', // hint: sronly stands for screen-reader only 'sronly_mcusername' => 'Minecraft Username (Premium)', @@ -179,6 +180,7 @@ return [ 'upcoming' => 'Your upcoming interviews', 'soon' => 'Coming soon', + //=================== ADMINISTRATION MESSAGES (for all administration pages) =============== 'adm' => 'Administration', @@ -196,6 +198,7 @@ return [ 'artisan_evaluate' => 'Artisan: Evaluate Votes Now', // Tip: Artisan is a program name, therefore not translatable 'devtools_info' => 'This panel may be also used to completely override the vote system in stalemate scenarios', + 'forms' => 'Forms', 'positions' => 'Positions', // Context: Positions as in job opening 'edit_form' => 'Edit Form', @@ -231,7 +234,7 @@ return [ 'cancel' => 'Cancel', 'close_vacancy' => 'Close Position', 'description_tooltip' => 'Add things like admission requirements, rank resposibilities and roles, and anything else you feel is necessary', - '', + '' ], @@ -249,7 +252,7 @@ return [ 'title' => 'Application Form Preview', 'looks' => 'This is how your form looks like to applicants', 'f_info' => 'You may edit it and add more fields later.', - '', + '' ], 'forms_p' => [ @@ -257,7 +260,7 @@ return [ 'available_forms' => 'Available forms', 'form_title' => 'Form title', 'empty_noforms' => 'Nothing to see here! Please add some forms first.', - 'new_form' => 'NEW FORM', + 'new_form' => 'NEW FORM' ], 'players' => [ @@ -278,7 +281,7 @@ return [ Registered players are those without a staff role in the team management application. There may be other users registered in the platform, but they won't be displayed here. ", - 'see_staff' => 'See Staff Members', + 'see_staff' => 'See Staff Members' ], @@ -302,7 +305,7 @@ return [ 'settings' => 'Settings', 'settings_header' => 'Notification Settings', 'settings_p' => 'Change which notifications are sent here.', - 'back_btn' => 'Back to Dashboard', + 'back_btn' => 'Back to Dashboard' ], @@ -328,17 +331,19 @@ return [ 'yrs_old' => 'Years old', // Context: "years old" as in: Tom is 24 years old 'line1' => 'We\'re glad you\'ve decided to apply. Generally, applications take 48 hours to be processed and reviewed. Depending on the circumstances and the volume of applications, you may receive an answer in a shorter time.', 'line2' => 'Please fill out the form below. Keep all answers concise and complete. Please keep in mind that the age requirement is at least :agerqr.', - 'line3' => 'Asking about your application will result in instant denial. Everything you need to know is here.', + 'line3' => 'Asking about your application will result in instant denial. Everything you need to know is here.' ], - 'app_timeout' => 'Your account is not permitted to submit another application. Please wait :days more days before trying to submit an application.', + 'app_timeout' => 'Your account is not permitted to submit another application. Please wait :days more days before trying to submit an application.' ], + 'application_m' => [ 'title' => 'Application Management', 'all_apps' => 'All Applications', 'modal_confirm' => 'Are you sure?', 'really_delete' => 'Really delete this?', + 'outstanding_sm' => 'Outstanding', 'outstanding_apps' => 'Outstanding Applications', 'outstanding_subm' => 'Outstanding (Submitted)', @@ -395,7 +400,7 @@ return [ 'title' => 'Voting Reminder', 'line1' => 'Applications which gain more than 50% of positive votes are automatically approved after one day.', 'line2' => 'Conversely, applications that do not reach this number are automatically denied.', - 'line3' => 'Please note that the vote system can be overridden', + 'line3' => 'Please note that the vote system can be overridden' ], @@ -516,7 +521,7 @@ return [ 'insta_user' => 'Instagram Username', 'discord_user' => 'Discord Handle', - 'update_prfl' => 'Update Profile', + 'update_prfl' => 'Update Profile' ], @@ -527,7 +532,7 @@ return [ 'app_process' => [ 'title' => 'Application Process', 'line1' => 'Please allow up to three days for your application to be processed. Your application will be reviewed by every team member, and will move up in stages.', - 'line2' => 'If an interview is scheduled, you\'ll need to open your application here and confirm the time, date, and location assigned for you.', + 'line2' => 'If an interview is scheduled, you\'ll need to open your application here and confirm the time, date, and location assigned for you.' ], 'account_standing' => 'Account Standing', @@ -546,9 +551,9 @@ return [ 'itsyou' => 'It\'s you!', 'title' => 'User Directory', - 'directory' => 'Directory', + 'directory' => 'Directory' - ], + ] ], @@ -585,7 +590,7 @@ return [ 'line1' => 'If you weren\'t present during this meeting, you can view the shared meeting notepad to help you make a decision.', 'line2' => 'You may vote on as many applications as needed; However, you can only vote once per application.', - 'line3' => 'Votes carry no weight based on rank. This system has been designed with fairness and ease of use in mind.', + 'line3' => 'Votes carry no weight based on rank. This system has been designed with fairness and ease of use in mind.' ], @@ -600,7 +605,7 @@ return [ 'max_chars' => 'max characters', // Context: A number is added before max characters 'post' => 'Post', // Context: Post as in post comment - ], + ] // ==================== END OF MAIN I18N FILE ====================== diff --git a/resources/lang/fr/pagination.php b/resources/lang/fr/pagination.php index 59d8a5d..d481411 100644 --- a/resources/lang/fr/pagination.php +++ b/resources/lang/fr/pagination.php @@ -1,24 +1,5 @@ . - */ - return [ /* diff --git a/resources/lang/fr/passwords.php b/resources/lang/fr/passwords.php index 8957598..2345a56 100644 --- a/resources/lang/fr/passwords.php +++ b/resources/lang/fr/passwords.php @@ -1,24 +1,5 @@ . - */ - return [ /* diff --git a/resources/lang/fr/validation.php b/resources/lang/fr/validation.php index b5f1b29..a65914f 100644 --- a/resources/lang/fr/validation.php +++ b/resources/lang/fr/validation.php @@ -1,24 +1,5 @@ . - */ - return [ /* diff --git a/resources/lang/pt/auth.php b/resources/lang/pt/auth.php index bb63a28..fffd887 100644 --- a/resources/lang/pt/auth.php +++ b/resources/lang/pt/auth.php @@ -1,24 +1,5 @@ . - */ - return [ /* diff --git a/resources/lang/pt/messages.php b/resources/lang/pt/messages.php index 78123b1..bc83c18 100644 --- a/resources/lang/pt/messages.php +++ b/resources/lang/pt/messages.php @@ -1,28 +1,24 @@ 'translate-me' + * Also, don't translate, change, or move placeholders (:this-is-a-placeholder) starting with a colon. + * Try to keep the message as close to the original in meaning as possible. These simple rules also apply to other files you're translating, such as: + * auth.php, pagination.php, passwords.php, and validation.php. + * It is VERY important that you "escape" single quotes with a backslash if they're present in your language, like this: I\'m an escaped quote * - * This file is part of Raspberry Staff Manager. + * Additionally, don't change anything in square or curly brackets, and don't remove pipe (|) characters. + * If you see two messages separated by pipe, then usually the left side is singular and the right side is plural, so translate accordingly. * - * 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 . + * Thank you for translating! */ return [ // ============== MENU TRANSLATIONS ====================== + 'menu' => [ 'my_apps' => 'As minhas Candidaturas', @@ -32,9 +28,11 @@ return [ 'all_forms' => 'Todos os Formulários', 'app_settings' => 'Configurações da App', 'global_app_settings' => 'Configurações globais do aplicativo', - 'system_logs' => 'Registos do Sistema', + 'system_logs' => 'Registos do Sistema' ], + + // ============== REUSABLE, GENERIC STRINGS =============== 'reusable' => [ @@ -81,9 +79,10 @@ return [ 'platform' => 'Plataforma', 'notepad' => 'Bloco Notas Partilhado', // Context: The shared notepad that appears when votes are needed, 'appointment_info' => 'Informação da Marcação', - 'ip_info' => 'Informação de Endereço IP para', + 'ip_info' => 'Informação de Endereço IP para' ], + // ============== HOMEPAGE MESSAGES ====================== 'home' => 'Início', @@ -126,6 +125,8 @@ return [ 'contactlabel_subject' => 'Assunto (ex. sugestão do site)', 'contactlabel_send' => 'Enviar', + + // ======================== AUTHENTICATION MESSAGES =========================== '2fa_txt' => 'Autenticação de dois Fatores', @@ -150,7 +151,7 @@ return [ 'line4' => 'Um mínimo de 10 caracteres;', 'line5' => 'Pelo menos 3 caracteres maiúsculos;', 'line6' => 'Pelo menos 3 números;', - 'line7' => 'Números e caracteres especiais.', + 'line7' => 'Números e caracteres especiais.' ], 'sronly_confirmpassword' => 'Confirmar palavra-passe', // hint: sronly stands for screen-reader only 'sronly_mcusername' => 'Utilizador do Minecraft (Premium)', @@ -179,6 +180,7 @@ return [ 'upcoming' => 'As suas próximas entrevistas', 'soon' => 'Disponível em breve', + //=================== ADMINISTRATION MESSAGES (for all administration pages) =============== 'adm' => 'Administração', @@ -196,6 +198,7 @@ return [ 'artisan_evaluate' => 'Artisan: Avaliar Votos Agora', // Tip: Artisan is a program name, therefore not translatable 'devtools_info' => 'Este painel também pode ser usado para substituir completamente o sistema de votação em cenários de impasse', + 'forms' => 'Formulários', 'positions' => 'Vagas', // Context: Positions as in job opening 'edit_form' => 'Editar Formulário', @@ -231,7 +234,7 @@ return [ 'cancel' => 'Cancelar', 'close_vacancy' => 'Fechar vaga', 'description_tooltip' => 'Adicione coisas como requisitos de admissão, responsabilidades e funções, e qualquer outra coisa que você ache necessária', - '', + '' ], @@ -249,7 +252,7 @@ return [ 'title' => 'Pré-visualização do Formulário de Candidatura', 'looks' => 'É assim que o seu formulário aparece para os candidatos', 'f_info' => 'Você pode editá-lo e adicionar mais campos posteriormente.', - '', + '' ], 'forms_p' => [ @@ -257,7 +260,7 @@ return [ 'available_forms' => 'Formulários disponíveis', 'form_title' => 'Título do Formulário', 'empty_noforms' => 'Nada para ver aqui! Por favor, crie alguns formulários primeiro.', - 'new_form' => 'NOVO FORMULÁRIO', + 'new_form' => 'NOVO FORMULÁRIO' ], 'players' => [ @@ -274,11 +277,11 @@ return [ 'banned' => 'Banido', 'active' => 'Ativo', 'no_reg' => 'Não há jogadores inscritos!', - 'no_reg_exp' => ' + 'no_reg_exp' => " Jogadores registados são aqueles que não possuem uma função administrativa no aplicativo de gestão de equipa. Pode haver outros utilizadores registados na plataforma, mas eles não serão exibidos aqui. -', - 'see_staff' => 'Ver Membros da Equipa', +", + 'see_staff' => 'Ver Membros da Equipa' ], @@ -286,11 +289,11 @@ return [ 'application_form' => 'Formulário de Candidatura', 'select_form' => 'Selecione um formulário...', - 'no_form_error' => ' + 'no_form_error' => " Não pode criar uma vaga sem qualquer formulário cujos quais as pessoas se poderiam candidatar. Crie um formulário primeiro, e depois crie uma vaga. Um único formulário pode ter várias vagas, para que possa anexar futuras vagas ao mesmo formulário, se quiser. -', +", 'new_pos' => 'NOVA VAGA', 'empty_pos_warning' => 'Nada para ver aqui! Abra algumas vagas primeiro. Isso fará os candidatos aparecerem! (esperançoso)', 'manage_forms' => 'GERIR FORMULÁRIOS DE CANDIDATURA', @@ -302,7 +305,7 @@ return [ 'settings' => 'Definições', 'settings_header' => 'Configuração das notificações', 'settings_p' => 'Altere quais notificações são enviadas aqui.', - 'back_btn' => 'Voltar ao painel', + 'back_btn' => 'Voltar ao painel' ], @@ -328,17 +331,19 @@ return [ 'yrs_old' => 'Anos de idade', // Context: "years old" as in: Tom is 24 years old 'line1' => 'Estamos felizes que você decidiu se candidatar. Geralmente, as candidaturas levam 48 horas para serem processadas e revisadas. Dependendo das circunstâncias e do volume de candidaturas, você poderá receber uma resposta em um período mais curto de tempo.', 'line2' => 'Por favor, preencha o formulário abaixo. Mantenha todas as respostas concisas e completas. Lembre-se de que o requisito de idade é de pelo menos :agerqr.', - 'line3' => 'Perguntar sobre a sua candidatura resultará em ser negado instantaneamente. Tudo o que você precisa saber está aqui.', + 'line3' => 'Perguntar sobre a sua candidatura resultará em ser negado instantaneamente. Tudo o que você precisa saber está aqui.' ], - 'app_timeout' => 'A sua conta não pode enviar outra candidatura. Por favor, espere :days mais dias antes de tentar enviar uma candidatura.', + 'app_timeout' => 'A sua conta não pode enviar outra candidatura. Por favor, espere :days mais dias antes de tentar enviar uma candidatura.' ], + 'application_m' => [ 'title' => 'Gestão de Candidaturas', 'all_apps' => 'Todas as Candidaturas', 'modal_confirm' => 'Tem a certeza?', 'really_delete' => 'Deseja realmente excluir isto?', + 'outstanding_sm' => 'Pendente', 'outstanding_apps' => 'Candidaturas Pendendes', 'outstanding_subm' => 'Pendente (Enviado)', @@ -395,7 +400,7 @@ return [ 'title' => 'Lembrete de votação', 'line1' => 'Candidaturas que obtêm mais de 50% dos votos positivos são automaticamente aprovadas após um dia.', 'line2' => 'Inversamente, candidaturas que não atingem esse número são automaticamente negadas.', - 'line3' => 'Por favor, lembre-se que o sistema de votação pode ser substituído', + 'line3' => 'Por favor, lembre-se que o sistema de votação pode ser substituído' ], @@ -516,7 +521,7 @@ return [ 'insta_user' => 'Nome de Utilizador do Instagram', 'discord_user' => '"Handle" do Discord', - 'update_prfl' => 'Atualizar Perfil', + 'update_prfl' => 'Atualizar Perfil' ], @@ -527,7 +532,7 @@ return [ 'app_process' => [ 'title' => 'Processo de Candidatura', 'line1' => 'Por favor, aguarde pelo menos três dias para que sua candidatura seja processada. A inscrição será revisada por todos os membros da equipa, e será promovida em fases.', - 'line2' => 'Se uma entrevista estiver programada, você precisará abrir o aplicativo aqui e confirmar a hora, data e local atribuídos para você.', + 'line2' => 'Se uma entrevista estiver programada, você precisará abrir o aplicativo aqui e confirmar a hora, data e local atribuídos para você.' ], 'account_standing' => 'Estado da Conta', @@ -546,9 +551,9 @@ return [ 'itsyou' => 'É você!', 'title' => 'Diretório de Utilizadores', - 'directory' => 'Diretório', + 'directory' => 'Diretório' - ], + ] ], @@ -585,7 +590,7 @@ return [ 'line1' => 'Se você não estava presente durante esta reunião, pode visualizar o bloco de notas da reunião partilhado para ajudá-lo a tomar uma decisão.', 'line2' => 'Você pode votar em quantas candidaturas forem necessárias; no entanto, só pode votar uma vez por candidatura.', - 'line3' => 'Os votos não têm peso baseado no cargo. Esse sistema foi projetado com justiça e facilidade de uso em mente.', + 'line3' => 'Os votos não têm peso baseado no cargo. Esse sistema foi projetado com justiça e facilidade de uso em mente.' ], @@ -600,7 +605,7 @@ return [ 'max_chars' => 'caracteres no máximo', // Context: A number is added before max characters 'post' => 'Publicar', // Context: Post as in post comment - ], + ] // ==================== END OF MAIN I18N FILE ====================== diff --git a/resources/lang/pt/pagination.php b/resources/lang/pt/pagination.php index bed9cc9..afe7439 100644 --- a/resources/lang/pt/pagination.php +++ b/resources/lang/pt/pagination.php @@ -1,24 +1,5 @@ . - */ - return [ /* diff --git a/resources/lang/pt/passwords.php b/resources/lang/pt/passwords.php index 0f19f79..178ca4f 100644 --- a/resources/lang/pt/passwords.php +++ b/resources/lang/pt/passwords.php @@ -1,24 +1,5 @@ . - */ - return [ /* @@ -36,6 +17,6 @@ return [ 'sent' => 'Enviamos um e-mail com um link para redefinir a sua password!', 'throttled' => 'Por favor, aguarde antes de tentar novamente.', 'token' => 'Token para recuperação de senha inválido.', - 'user' => 'Não foi possível encontrar um utilizador com este e-mail.', + 'user' => "Não foi possível encontrar um utilizador com este e-mail.", ]; diff --git a/resources/lang/pt/validation.php b/resources/lang/pt/validation.php index 6e69bb1..c167208 100644 --- a/resources/lang/pt/validation.php +++ b/resources/lang/pt/validation.php @@ -1,24 +1,5 @@ . - */ - return [ /* diff --git a/routes/api.php b/routes/api.php index b473196..bcb8b18 100644 --- a/routes/api.php +++ b/routes/api.php @@ -1,24 +1,5 @@ . - */ - use Illuminate\Http\Request; use Illuminate\Support\Facades\Route; diff --git a/routes/channels.php b/routes/channels.php index a5399ff..963b0d2 100644 --- a/routes/channels.php +++ b/routes/channels.php @@ -1,24 +1,5 @@ . - */ - use Illuminate\Support\Facades\Broadcast; /* diff --git a/routes/console.php b/routes/console.php index 8a11008..da55196 100644 --- a/routes/console.php +++ b/routes/console.php @@ -1,24 +1,5 @@ . - */ - use Illuminate\Foundation\Inspiring; use Illuminate\Support\Facades\Artisan; diff --git a/routes/web.php b/routes/web.php index 201154e..87a50da 100644 --- a/routes/web.php +++ b/routes/web.php @@ -1,24 +1,5 @@ . - */ - use Illuminate\Support\Facades\Route; use Mcamara\LaravelLocalization\Facades\LaravelLocalization; @@ -32,21 +13,26 @@ use Mcamara\LaravelLocalization\Facades\LaravelLocalization; | contains the "web" middleware group. Now create something great! | */ -Route::group(['prefix' => LaravelLocalization::setLocale(), 'middleware' => ['localeSessionRedirect', 'localizationRedirect', 'localeViewPath']], function () { - Route::group(['prefix' => 'auth', 'middleware' => ['usernameUUID']], function () { +Route::group(['prefix' => LaravelLocalization::setLocale(), 'middleware' => [ 'localeSessionRedirect', 'localizationRedirect', 'localeViewPath' ]], function (){ + + Route::group(['prefix' => 'auth', 'middleware' => ['usernameUUID']], function (){ + Auth::routes(['verify' => true]); Route::post('/twofa/authenticate', 'Auth\TwofaController@verify2FA') ->name('verify2FA'); + }); - Route::get('/', 'HomeController@index') + Route::get('/','HomeController@index') ->middleware('eligibility'); Route::post('/form/contact', 'ContactController@create') ->name('sendSubmission'); - Route::group(['middleware' => ['auth', 'forcelogout', '2fa', 'verified']], function () { + + Route::group(['middleware' => ['auth', 'forcelogout', '2fa', 'verified']], function(){ + Route::get('/dashboard', 'DashboardController@index') ->name('dashboard') ->middleware('eligibility'); @@ -54,7 +40,8 @@ Route::group(['prefix' => LaravelLocalization::setLocale(), 'middleware' => ['lo Route::get('users/directory', 'ProfileController@index') ->name('directory'); - Route::group(['prefix' => '/applications'], function () { + Route::group(['prefix' => '/applications'], function (){ + Route::get('/my-applications', 'ApplicationController@showUserApps') ->name('showUserApps') ->middleware('eligibility'); @@ -68,48 +55,63 @@ Route::group(['prefix' => LaravelLocalization::setLocale(), 'middleware' => ['lo Route::delete('/comments/{comment}/delete', 'CommentController@delete') ->name('deleteApplicationComment'); + Route::patch('/notes/save/{application}', 'AppointmentController@saveNotes') ->name('saveNotes'); + Route::patch('/update/{application}/{newStatus}', 'ApplicationController@updateApplicationStatus') ->name('updateApplicationStatus'); Route::delete('{application}/delete', 'ApplicationController@delete') ->name('deleteApplication'); + Route::get('/staff/all', 'ApplicationController@showAllApps') ->name('allApplications'); + Route::get('/staff/outstanding', 'ApplicationController@showAllPendingApps') ->name('staffPendingApps'); + Route::get('/staff/peer-review', 'ApplicationController@showPeerReview') ->name('peerReview'); + Route::get('/staff/pending-interview', 'ApplicationController@showPendingInterview') ->name('pendingInterview'); + + Route::post('{application}/staff/vote', 'VoteController@vote') ->name('voteApplication'); + + }); - Route::group(['prefix' => 'appointments'], function () { + Route::group(['prefix' => 'appointments'], function (){ + Route::post('schedule/appointments/{application}', 'AppointmentController@saveAppointment') ->name('scheduleAppointment'); Route::patch('update/appointments/{application}/{status}', 'AppointmentController@updateAppointment') ->name('updateAppointment'); + }); - Route::group(['prefix' => 'apply', 'middleware' => ['eligibility']], function () { + Route::group(['prefix' => 'apply', 'middleware' => ['eligibility']], function (){ + Route::get('positions/{vacancySlug}', 'ApplicationController@renderApplicationForm') ->name('renderApplicationForm'); Route::post('positions/{vacancySlug}/submit', 'ApplicationController@saveApplicationAnswers') ->name('saveApplicationForm'); + }); - Route::group(['prefix' => '/profile'], function () { + Route::group(['prefix' => '/profile'], function (){ + Route::get('/settings', 'ProfileController@showProfile') ->name('showProfileSettings'); @@ -119,9 +121,11 @@ Route::group(['prefix' => LaravelLocalization::setLocale(), 'middleware' => ['lo Route::get('user/{user}', 'ProfileController@showSingleProfile') ->name('showSingleProfile'); + Route::get('/settings/account', 'UserController@showAccount') ->name('showAccountSettings'); + Route::patch('/settings/account/change-password', 'UserController@changePassword') ->name('changePassword'); @@ -136,9 +140,12 @@ Route::group(['prefix' => LaravelLocalization::setLocale(), 'middleware' => ['lo Route::patch('/settings/account/twofa/disable', 'UserController@remove2FASecret') ->name('disable2FA'); + }); - Route::group(['prefix' => '/hr'], function () { + + Route::group(['prefix' => '/hr'], function (){ + Route::get('staff-members', 'UserController@showStaffMembers') ->name('staffMemberList'); @@ -150,9 +157,11 @@ Route::group(['prefix' => LaravelLocalization::setLocale(), 'middleware' => ['lo Route::patch('staff-members/terminate/{user}', 'UserController@terminate') ->name('terminateStaffMember'); + }); - Route::group(['prefix' => 'admin'], function () { + Route::group(['prefix' => 'admin'], function (){ + Route::get('settings', 'OptionsController@index') ->name('showSettings'); @@ -165,27 +174,34 @@ Route::group(['prefix' => LaravelLocalization::setLocale(), 'middleware' => ['lo Route::delete('players/unban/{user}', 'BanController@delete') ->name('unbanUser'); + + Route::delete('players/delete/{user}', 'UserController@delete') ->name('deleteUser'); Route::patch('players/update/{user}', 'UserController@update') ->name('updateUser'); + + Route::get('positions', 'VacancyController@index') ->name('showPositions'); Route::post('positions/save', 'VacancyController@store') ->name('savePosition'); + Route::get('positions/edit/{vacancy}', 'VacancyController@edit') ->name('editPosition'); Route::patch('positions/update/{vacancy}', 'VacancyController@update') ->name('updatePosition'); + Route::patch('positions/availability/{status}/{vacancy}', 'VacancyController@updatePositionAvailability') ->name('updatePositionAvailability'); + Route::get('forms/builder', 'FormController@showFormBuilder') ->name('showFormBuilder'); @@ -207,12 +223,17 @@ Route::group(['prefix' => LaravelLocalization::setLocale(), 'middleware' => ['lo Route::patch('forms/update/{form}', 'FormController@update') ->name('updateForm'); + Route::get('devtools', 'DevToolsController@index') ->name('devTools'); // we could use route model binding Route::post('devtools/vote-evaluation/force', 'DevToolsController@forceVoteCount') ->name('devToolsForceVoteCount'); + }); + }); }); + + diff --git a/server.php b/server.php index 8fef71b..5fb6379 100644 --- a/server.php +++ b/server.php @@ -1,22 +1,10 @@ . + * @package Laravel + * @author Taylor Otwell */ $uri = urldecode( diff --git a/tests/CreatesApplication.php b/tests/CreatesApplication.php index 0320f1f..547152f 100644 --- a/tests/CreatesApplication.php +++ b/tests/CreatesApplication.php @@ -1,24 +1,5 @@ . - */ - namespace Tests; use Illuminate\Contracts\Console\Kernel; diff --git a/tests/Feature/ExampleTest.php b/tests/Feature/ExampleTest.php index 0ad542e..cdb5111 100644 --- a/tests/Feature/ExampleTest.php +++ b/tests/Feature/ExampleTest.php @@ -1,26 +1,8 @@ . - */ - namespace Tests\Feature; +use Illuminate\Foundation\Testing\RefreshDatabase; use Tests\TestCase; class ExampleTest extends TestCase diff --git a/tests/Feature/OptionsTest.php b/tests/Feature/OptionsTest.php index d06358e..08a68f5 100644 --- a/tests/Feature/OptionsTest.php +++ b/tests/Feature/OptionsTest.php @@ -1,26 +1,9 @@ . - */ - namespace Tests\Feature; +use Illuminate\Foundation\Testing\RefreshDatabase; +use Illuminate\Foundation\Testing\WithFaker; use Tests\TestCase; class OptionsTest extends TestCase diff --git a/tests/TestCase.php b/tests/TestCase.php index 3997b9e..2932d4a 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -1,24 +1,5 @@ . - */ - namespace Tests; use Illuminate\Foundation\Testing\TestCase as BaseTestCase; diff --git a/tests/Unit/ExampleTest.php b/tests/Unit/ExampleTest.php index 2d151d7..358cfc8 100644 --- a/tests/Unit/ExampleTest.php +++ b/tests/Unit/ExampleTest.php @@ -1,24 +1,5 @@ . - */ - namespace Tests\Unit; use PHPUnit\Framework\TestCase;