Merge remote-tracking branch 'origin/develop' into develop

# Conflicts:
#	app/Http/Controllers/TeamFileController.php
#	app/TeamFile.php
#	config/adminlte.php
#	routes/web.php
This commit is contained in:
Miguel Nogueira 2020-11-02 21:50:30 +00:00
commit e4fb438721
10 changed files with 214 additions and 68 deletions

View File

@ -1,5 +1,24 @@
<?php <?php
/*
* Copyright © 2020 Miguel Nogueira
*
* This file is part of Raspberry Staff Manager.
*
* Raspberry Staff Manager is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Raspberry Staff Manager is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Raspberry Staff Manager. If not, see <https://www.gnu.org/licenses/>.
*/
namespace App\Console\Commands; namespace App\Console\Commands;
use App\Facades\UUID; use App\Facades\UUID;
@ -23,6 +42,7 @@ class CreateUser extends Command
* @var string * @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.'; 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. * Create a new command instance.
* *
@ -40,9 +60,7 @@ class CreateUser extends Command
*/ */
public function handle() public function handle()
{ {
do {
do
{
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
system('cls'); system('cls');
} else { } else {
@ -53,60 +71,43 @@ class CreateUser extends Command
$this->info('We\'ll ask some questions to get you started.'); $this->info('We\'ll ask some questions to get you started.');
$username = $this->ask('Username'); $username = $this->ask('Username');
do do {
{
$password = $this->secret('Password'); $password = $this->secret('Password');
$password_confirm = $this->secret('Confirm Password'); $password_confirm = $this->secret('Confirm Password');
if ($password === $password_confirm) if ($password === $password_confirm) {
{
$password = Hash::make($password); $password = Hash::make($password);
$matches = true; $matches = true;
} } else {
else
{
$this->error('Password doesn\'t match. Please try again.'); $this->error('Password doesn\'t match. Please try again.');
$matches = false; $matches = false;
} }
} } while (! $matches);
while(!$matches);
$email = $this->ask('E-mail address'); $email = $this->ask('E-mail address');
$name = $this->ask('First/Last Name'); $name = $this->ask('First/Last Name');
do do {
{ try {
try
{
$uuid = UUID::toUUID($this->ask('Minecraft username (Must be a valid Premium account)')); $uuid = UUID::toUUID($this->ask('Minecraft username (Must be a valid Premium account)'));
} } catch (\InvalidArgumentException $e) {
catch (\InvalidArgumentException $e)
{
$this->error($e->getMessage()); $this->error($e->getMessage());
$hasError = true; $hasError = true;
} }
if (isset($hasError)) if (isset($hasError)) {
{
$continue = true; $continue = true;
} } else {
else
{
$continue = false; $continue = false;
} }
unset($hasError); unset($hasError);
} } while ($continue);
while($continue);
$this->info('Please check if these details are correct: '); $this->info('Please check if these details are correct: ');
$this->info('Username: ' . $username); $this->info('Username: '.$username);
$this->info('Email: ' . $email); $this->info('Email: '.$email);
$this->info('Name: ' . $name); $this->info('Name: '.$name);
} while (! $this->confirm('Create user now? You can go back to correct any details.'));
}
while(!$this->confirm('Create user now? You can go back to correct any details.'));
$user = User::create([ $user = User::create([
'uuid' => $uuid, 'uuid' => $uuid,
@ -114,11 +115,10 @@ class CreateUser extends Command
'email' => $email, 'email' => $email,
'username' => $username, 'username' => $username,
'originalIP' => '127.0.0.1', 'originalIP' => '127.0.0.1',
'password' => $password 'password' => $password,
]); ]);
if ($user) if ($user) {
{
$user->assignRole('admin', 'reviewer', 'user', 'hiringManager'); $user->assignRole('admin', 'reviewer', 'user', 'hiringManager');
Profile::create([ Profile::create([
'profileShortBio' => 'Random data '.rand(0, 1000), 'profileShortBio' => 'Random data '.rand(0, 1000),
@ -128,13 +128,12 @@ class CreateUser extends Command
'userID' => $user->id, '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; return 0;
} } else {
else
{
$this->error('There was an unknown problem creating the user. There might have been errors above. Please try again.'); $this->error('There was an unknown problem creating the user. There might have been errors above. Please try again.');
return 1; return 1;
} }
} }

View File

@ -1,12 +1,29 @@
<?php <?php
/*
* Copyright © 2020 Miguel Nogueira
*
* This file is part of Raspberry Staff Manager.
*
* Raspberry Staff Manager is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Raspberry Staff Manager is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Raspberry Staff Manager. If not, see <https://www.gnu.org/licenses/>.
*/
namespace App\Console\Commands; namespace App\Console\Commands;
use Faker\Factory; use Faker\Factory;
use Faker\Generator; use Faker\Generator;
use Illuminate\Console\Command; use Illuminate\Console\Command;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Storage; use Illuminate\Support\Facades\Storage;
class MakeFile extends Command 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.'; protected $description = 'Generates test files for the TeamFile model. Use in conjunction with it\'s factory.';
/** /**
* The faker instance used to obtain dummy text. * The faker instance used to obtain dummy text.
* *
@ -53,15 +69,14 @@ class MakeFile extends Command
public function handle() public function handle()
{ {
$count = $this->argument('count'); $count = $this->argument('count');
$this->info('Creating ' . $this->argument('count') . ' files!'); $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));
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.'); $this->info('Finished creating files! They will be randomly picked by the factory.');
return 0; return 0;
} }
} }

View File

@ -37,7 +37,6 @@ class Team extends TeamworkTeam
return $this->belongsToMany('App\Vacancy', 'team_has_vacancy'); return $this->belongsToMany('App\Vacancy', 'team_has_vacancy');
} }
public function files() public function files()
{ {
return $this->hasMany('App\TeamFile', 'team_id'); return $this->hasMany('App\TeamFile', 'team_id');

View File

@ -1,5 +1,24 @@
<?php <?php
/*
* Copyright © 2020 Miguel Nogueira
*
* This file is part of Raspberry Staff Manager.
*
* Raspberry Staff Manager is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Raspberry Staff Manager is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Raspberry Staff Manager. If not, see <https://www.gnu.org/licenses/>.
*/
return [ return [
/* /*

View File

@ -1,5 +1,24 @@
<?php <?php
/*
* Copyright © 2020 Miguel Nogueira
*
* This file is part of Raspberry Staff Manager.
*
* Raspberry Staff Manager is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Raspberry Staff Manager is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Raspberry Staff Manager. If not, see <https://www.gnu.org/licenses/>.
*/
return [ return [
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------

View File

@ -1,23 +1,42 @@
<?php <?php
return array( /*
* Copyright © 2020 Miguel Nogueira
*
* This file is part of Raspberry Staff Manager.
*
* Raspberry Staff Manager is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Raspberry Staff Manager is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Raspberry Staff Manager. If not, see <https://www.gnu.org/licenses/>.
*/
return [
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
| One Signal App Id | One Signal App Id
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
| |
| |
*/ */
'app_id' => 'YOUR-APP-ID-HERE', 'app_id' => 'YOUR-APP-ID-HERE',
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
| Rest API Key | Rest API Key
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
|
| |
| |
*/ |
*/
'rest_api_key' => 'YOUR-REST-API-KEY-HERE', 'rest_api_key' => 'YOUR-REST-API-KEY-HERE',
'user_auth_key' => 'YOUR-USER-AUTH-KEY' 'user_auth_key' => 'YOUR-USER-AUTH-KEY',
); ];

View File

@ -1,5 +1,24 @@
<?php <?php
/*
* Copyright © 2020 Miguel Nogueira
*
* This file is part of Raspberry Staff Manager.
*
* Raspberry Staff Manager is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Raspberry Staff Manager is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Raspberry Staff Manager. If not, see <https://www.gnu.org/licenses/>.
*/
namespace Database\Factories; namespace Database\Factories;
use App\TeamFile; use App\TeamFile;
@ -27,12 +46,12 @@ class TeamFileFactory extends Factory
return [ return [
'uploaded_by' => rand(1, 10), // Also assuming that the user seeder has ran before '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 '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(), 'caption' => $this->faker->sentence(),
'description' => $this->faker->paragraphs(3, true), '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', '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
]; ];
} }
} }

View File

@ -1,5 +1,24 @@
<?php <?php
/*
* Copyright © 2020 Miguel Nogueira
*
* This file is part of Raspberry Staff Manager.
*
* Raspberry Staff Manager is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Raspberry Staff Manager is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Raspberry Staff Manager. If not, see <https://www.gnu.org/licenses/>.
*/
use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\Schema;

View File

@ -1,5 +1,24 @@
<?php <?php
/*
* Copyright © 2020 Miguel Nogueira
*
* This file is part of Raspberry Staff Manager.
*
* Raspberry Staff Manager is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Raspberry Staff Manager is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Raspberry Staff Manager. If not, see <https://www.gnu.org/licenses/>.
*/
use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\Schema;

View File

@ -1,5 +1,24 @@
<?php <?php
/*
* Copyright © 2020 Miguel Nogueira
*
* This file is part of Raspberry Staff Manager.
*
* Raspberry Staff Manager is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Raspberry Staff Manager is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Raspberry Staff Manager. If not, see <https://www.gnu.org/licenses/>.
*/
namespace Database\Seeders; namespace Database\Seeders;
use App\TeamFile; use App\TeamFile;