From d5d23b7dbd4e57ad732ec476dc5ffcdd86b35e14 Mon Sep 17 00:00:00 2001 From: Miguel Nogueira Date: Sun, 11 Oct 2020 01:54:22 +0000 Subject: [PATCH] Apply fixes from StyleCI --- app/Console/Commands/CreateUser.php | 81 +++++++++---------- app/Console/Commands/MakeFile.php | 31 +++++-- app/Http/Controllers/TeamFileController.php | 37 ++++++--- app/Team.php | 1 - app/TeamFile.php | 22 ++++- config/adminlte.php | 10 +-- config/debugbar.php | 19 +++++ config/env-editor.php | 19 +++++ config/onesignal.php | 49 +++++++---- database/factories/TeamFileFactory.php | 25 +++++- ...0_10_10_185952_create_team_files_table.php | 19 +++++ ...10_10_235319_add_details_to_team_files.php | 19 +++++ database/seeders/TeamFileSeeder.php | 19 +++++ routes/web.php | 2 - 14 files changed, 265 insertions(+), 88 deletions(-) diff --git a/app/Console/Commands/CreateUser.php b/app/Console/Commands/CreateUser.php index 4cbd007..eb98a8d 100644 --- a/app/Console/Commands/CreateUser.php +++ b/app/Console/Commands/CreateUser.php @@ -1,5 +1,24 @@ . + */ + namespace App\Console\Commands; use App\Facades\UUID; @@ -23,6 +42,7 @@ class CreateUser extends Command * @var string */ protected $description = 'Creates an application user. Seeding the database is for testing environments, so use this command in production for your first admin user.'; + /** * Create a new command instance. * @@ -40,9 +60,7 @@ class CreateUser extends Command */ public function handle() { - - do - { + do { if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { system('cls'); } else { @@ -53,60 +71,43 @@ class CreateUser extends Command $this->info('We\'ll ask some questions to get you started.'); $username = $this->ask('Username'); - do - { + do { $password = $this->secret('Password'); $password_confirm = $this->secret('Confirm Password'); - if ($password === $password_confirm) - { + if ($password === $password_confirm) { $password = Hash::make($password); $matches = true; - } - else - { + } else { $this->error('Password doesn\'t match. Please try again.'); $matches = false; } - } - while(!$matches); + } while (! $matches); $email = $this->ask('E-mail address'); $name = $this->ask('First/Last Name'); - do - { - try - { + do { + try { $uuid = UUID::toUUID($this->ask('Minecraft username (Must be a valid Premium account)')); - } - catch (\InvalidArgumentException $e) - { + } catch (\InvalidArgumentException $e) { $this->error($e->getMessage()); $hasError = true; } - if (isset($hasError)) - { + if (isset($hasError)) { $continue = true; - } - else - { + } else { $continue = false; } unset($hasError); - } - while($continue); - + } while ($continue); $this->info('Please check if these details are correct: '); - $this->info('Username: ' . $username); - $this->info('Email: ' . $email); - $this->info('Name: ' . $name); - - } - while(!$this->confirm('Create user now? You can go back to correct any details.')); - + $this->info('Username: '.$username); + $this->info('Email: '.$email); + $this->info('Name: '.$name); + } while (! $this->confirm('Create user now? You can go back to correct any details.')); $user = User::create([ 'uuid' => $uuid, @@ -114,11 +115,10 @@ class CreateUser extends Command 'email' => $email, 'username' => $username, 'originalIP' => '127.0.0.1', - 'password' => $password + 'password' => $password, ]); - if ($user) - { + if ($user) { $user->assignRole('admin', 'reviewer', 'user', 'hiringManager'); Profile::create([ 'profileShortBio' => 'Random data '.rand(0, 1000), @@ -128,13 +128,12 @@ class CreateUser extends Command 'userID' => $user->id, ]); - $this->info('Account created! You may now login at ' . route('login') . '. Enjoy the app!'); + $this->info('Account created! You may now login at '.route('login').'. Enjoy the app!'); return 0; - } - else - { + } else { $this->error('There was an unknown problem creating the user. There might have been errors above. Please try again.'); + return 1; } } diff --git a/app/Console/Commands/MakeFile.php b/app/Console/Commands/MakeFile.php index 47e7a77..5d3cf40 100644 --- a/app/Console/Commands/MakeFile.php +++ b/app/Console/Commands/MakeFile.php @@ -1,12 +1,29 @@ . + */ + namespace App\Console\Commands; use Faker\Factory; use Faker\Generator; - use Illuminate\Console\Command; -use Illuminate\Support\Facades\Http; use Illuminate\Support\Facades\Storage; class MakeFile extends Command @@ -25,7 +42,6 @@ class MakeFile extends Command */ protected $description = 'Generates test files for the TeamFile model. Use in conjunction with it\'s factory.'; - /** * The faker instance used to obtain dummy text. * @@ -53,15 +69,14 @@ class MakeFile extends Command public function handle() { $count = $this->argument('count'); - $this->info('Creating ' . $this->argument('count') . ' files!'); - - for ($max = 1; $max < $count; $max++) - { - Storage::disk('local')->put('factory_files/testfile_' . rand(0, 5000) . '.txt', $this->faker->paragraphs(40, true)); + $this->info('Creating '.$this->argument('count').' files!'); + for ($max = 1; $max < $count; $max++) { + Storage::disk('local')->put('factory_files/testfile_'.rand(0, 5000).'.txt', $this->faker->paragraphs(40, true)); } $this->info('Finished creating files! They will be randomly picked by the factory.'); + return 0; } } diff --git a/app/Http/Controllers/TeamFileController.php b/app/Http/Controllers/TeamFileController.php index b8a67e8..9bff027 100644 --- a/app/Http/Controllers/TeamFileController.php +++ b/app/Http/Controllers/TeamFileController.php @@ -1,5 +1,24 @@ . + */ + namespace App\Http\Controllers; use App\TeamFile; @@ -18,9 +37,9 @@ class TeamFileController extends Controller */ public function index(Request $request) { - if (is_null(Auth::user()->currentTeam)) - { + if (is_null(Auth::user()->currentTeam)) { $request->session()->flash('error', 'Please choose a team before viewing it\'s files.'); + return redirect()->to(route('teams.index')); } @@ -49,18 +68,14 @@ class TeamFileController extends Controller // } - public function download(Request $request, TeamFile $teamFile) { - try - { - return Storage::download('uploads/' . $teamFile->name); - } - catch (FileNotFoundException $ex) - { - $request->session()->flash('error', 'Sorry, but the requested file could not be found in storage. Sometimes, files may be physically deleted by admins, but not from the app\'s database.'); - return redirect()->back(); + try { + return Storage::download('uploads/'.$teamFile->name); + } catch (FileNotFoundException $ex) { + $request->session()->flash('error', 'Sorry, but the requested file could not be found in storage. Sometimes, files may be physically deleted by admins, but not from the app\'s database.'); + return redirect()->back(); } } diff --git a/app/Team.php b/app/Team.php index 27fe33c..77c372b 100644 --- a/app/Team.php +++ b/app/Team.php @@ -37,7 +37,6 @@ class Team extends TeamworkTeam return $this->belongsToMany('App\Vacancy', 'team_has_vacancy'); } - public function files() { return $this->hasMany('App\TeamFile', 'team_id'); diff --git a/app/TeamFile.php b/app/TeamFile.php index 8e54c14..e6018b6 100644 --- a/app/TeamFile.php +++ b/app/TeamFile.php @@ -1,5 +1,24 @@ . + */ + namespace App; use Illuminate\Database\Eloquent\Factories\HasFactory; @@ -10,13 +29,12 @@ class TeamFile extends Model { use HasFactory, UsedByTeams; - protected $fillable = [ 'uploaded_by', 'team_id', 'name', 'fs_location', - 'extension' + 'extension', ]; public function uploader() diff --git a/config/adminlte.php b/config/adminlte.php index 197962b..6b15609 100644 --- a/config/adminlte.php +++ b/config/adminlte.php @@ -616,14 +616,14 @@ return [ [ 'type' => 'js', 'asset' => false, - 'location' => '/js/plugins/dropzone.min.js' + 'location' => '/js/plugins/dropzone.min.js', ], [ 'type' => 'css', 'asset' => false, - 'location' => '/css/dropzone.min.css' - ] - ] - ] + 'location' => '/css/dropzone.min.css', + ], + ], + ], ], ]; diff --git a/config/debugbar.php b/config/debugbar.php index ada83c6..87b003e 100644 --- a/config/debugbar.php +++ b/config/debugbar.php @@ -1,5 +1,24 @@ . + */ + return [ /* diff --git a/config/env-editor.php b/config/env-editor.php index b58184a..7b56924 100644 --- a/config/env-editor.php +++ b/config/env-editor.php @@ -1,5 +1,24 @@ . + */ + return [ /* |-------------------------------------------------------------------------- diff --git a/config/onesignal.php b/config/onesignal.php index 8eb3448..aa03903 100644 --- a/config/onesignal.php +++ b/config/onesignal.php @@ -1,23 +1,42 @@ . + */ + +return [ /* - |-------------------------------------------------------------------------- - | One Signal App Id - |-------------------------------------------------------------------------- - | - | - */ + |-------------------------------------------------------------------------- + | One Signal App Id + |-------------------------------------------------------------------------- + | + | + */ 'app_id' => 'YOUR-APP-ID-HERE', /* - |-------------------------------------------------------------------------- - | Rest API Key - |-------------------------------------------------------------------------- - | + |-------------------------------------------------------------------------- + | Rest API Key + |-------------------------------------------------------------------------- | - | - */ + | + | + */ 'rest_api_key' => 'YOUR-REST-API-KEY-HERE', - 'user_auth_key' => 'YOUR-USER-AUTH-KEY' -); \ No newline at end of file + 'user_auth_key' => 'YOUR-USER-AUTH-KEY', +]; diff --git a/database/factories/TeamFileFactory.php b/database/factories/TeamFileFactory.php index 7782137..dc5abf1 100644 --- a/database/factories/TeamFileFactory.php +++ b/database/factories/TeamFileFactory.php @@ -1,5 +1,24 @@ . + */ + namespace Database\Factories; use App\TeamFile; @@ -27,12 +46,12 @@ class TeamFileFactory extends Factory return [ 'uploaded_by' => rand(1, 10), // Also assuming that the user seeder has ran before 'team_id' => rand(1, 3), // Assuming you create 3 teams beforehand - 'name' => $this->faker->file($prefix . 'factory_files', $prefix . 'uploads', false), + 'name' => $this->faker->file($prefix.'factory_files', $prefix.'uploads', false), 'caption' => $this->faker->sentence(), 'description' => $this->faker->paragraphs(3, true), - 'fs_location' => $this->faker->file($prefix . 'factory_files', $prefix . 'uploads'), + 'fs_location' => $this->faker->file($prefix.'factory_files', $prefix.'uploads'), 'extension' => 'txt', - 'size' => rand(1, 1000) // random fake size between 0 bytes and 1 mb + 'size' => rand(1, 1000), // random fake size between 0 bytes and 1 mb ]; } } diff --git a/database/migrations/2020_10_10_185952_create_team_files_table.php b/database/migrations/2020_10_10_185952_create_team_files_table.php index b1b0835..38a6714 100644 --- a/database/migrations/2020_10_10_185952_create_team_files_table.php +++ b/database/migrations/2020_10_10_185952_create_team_files_table.php @@ -1,5 +1,24 @@ . + */ + use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; diff --git a/database/migrations/2020_10_10_235319_add_details_to_team_files.php b/database/migrations/2020_10_10_235319_add_details_to_team_files.php index 0ea7fd0..577baf0 100644 --- a/database/migrations/2020_10_10_235319_add_details_to_team_files.php +++ b/database/migrations/2020_10_10_235319_add_details_to_team_files.php @@ -1,5 +1,24 @@ . + */ + use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; diff --git a/database/seeders/TeamFileSeeder.php b/database/seeders/TeamFileSeeder.php index 91f88c2..4e44a98 100644 --- a/database/seeders/TeamFileSeeder.php +++ b/database/seeders/TeamFileSeeder.php @@ -1,5 +1,24 @@ . + */ + namespace Database\Seeders; use App\TeamFile; diff --git a/routes/web.php b/routes/web.php index ab4452f..56c07f1 100644 --- a/routes/web.php +++ b/routes/web.php @@ -87,7 +87,6 @@ Route::group(['prefix' => LaravelLocalization::setLocale(), 'middleware' => ['lo Route::get('teams/invites/{action}/{token}', [TeamController::class, 'processInviteAction']) ->name('processInvite'); - Route::get('team/files', [TeamFileController::class, 'index']) ->name('showTeamFiles'); @@ -97,7 +96,6 @@ Route::group(['prefix' => LaravelLocalization::setLocale(), 'middleware' => ['lo Route::get('team/files/{teamFile}/download', [TeamFileController::class, 'download']) ->name('downloadTeamFile'); - Route::group(['prefix' => '/applications'], function () { Route::get('/my-applications', [ApplicationController::class, 'showUserApps']) ->name('showUserApps')