23
database/factories/ProfileFactory.php
Executable file
23
database/factories/ProfileFactory.php
Executable file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Profile>
|
||||
*/
|
||||
class ProfileFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition()
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
}
|
@@ -1,47 +1,36 @@
|
||||
<?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;
|
||||
|
||||
use App\User;
|
||||
use Faker\Generator as Faker;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Carbon;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Model Factories
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This directory should contain each of the model factory definitions for
|
||||
| your application. Factories provide a convenient way to generate new
|
||||
| model instances for testing / seeding your application's database.
|
||||
|
|
||||
*/
|
||||
|
||||
$factory->define(User::class, function (Faker $faker) {
|
||||
return [
|
||||
'name' => $faker->name,
|
||||
'email' => $faker->unique()->safeEmail,
|
||||
'email_verified_at' => now(),
|
||||
'password' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', // password
|
||||
'remember_token' => Str::random(10),
|
||||
];
|
||||
});
|
||||
/**
|
||||
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\User>
|
||||
*/
|
||||
class UserFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition()
|
||||
{
|
||||
return [
|
||||
'uuid' => $this->faker->uuid(),
|
||||
'name' => $this->faker->name(),
|
||||
'email' => $this->faker->unique()->safeEmail(),
|
||||
'email_verified_at' => Carbon::now(),
|
||||
'username' => $this->faker->userName(),
|
||||
'dob' => Carbon::now(),
|
||||
'password' => bcrypt($this->faker->password),
|
||||
'created_at' => Carbon::now(),
|
||||
'updated_at' => Carbon::now(),
|
||||
'password_last_updated' => Carbon::now(),
|
||||
'administratively_locked' => false,
|
||||
'registrationIp' => $this->faker->ipv4(),
|
||||
'currentIp' => $this->faker->ipv4(),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
0
database/migrations/.gitkeep
Normal file → Executable file
0
database/migrations/.gitkeep
Normal file → Executable file
0
database/migrations/2022_03_07_180241_remove_account_tokens_from_user.php
Normal file → Executable file
0
database/migrations/2022_03_07_180241_remove_account_tokens_from_user.php
Normal file → Executable file
34
database/migrations/2022_08_14_210735_add_registration_i_p_to_user.php
Executable file
34
database/migrations/2022_08_14_210735_add_registration_i_p_to_user.php
Executable file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->renameColumn('originalIP', 'currentIp');
|
||||
$table->ipAddress('registrationIp')->after('originalIP');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->renameColumn('currentIp', 'originalIP');
|
||||
$table->removeColumn('ipAddress');
|
||||
});
|
||||
}
|
||||
};
|
41
database/migrations/2022_08_20_195538_add_discord_to_users.php
Executable file
41
database/migrations/2022_08_20_195538_add_discord_to_users.php
Executable file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
|
||||
$table->string('password')->nullable()->change(); // social login requires no pw (still required upon normal reg)
|
||||
$table->string('registrationIp')->nullable()->change();
|
||||
|
||||
$table->unsignedBigInteger('discord_user_id')->after('remember_token')->nullable();
|
||||
$table->longText('discord_token')->after('discord_user_id')->nullable();
|
||||
$table->longText('discord_refresh_token')->after('discord_token')->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->dropColumn('discord_token', 'discord_refresh_token', 'discord_user_id');
|
||||
|
||||
$table->string('password')->nullable(false)->change();
|
||||
$table->string('registrationIp')->nullable(false)->change();
|
||||
});
|
||||
}
|
||||
};
|
22
database/migrations/2022_08_27_052451_add_int_profile_pic_to_users.php
Executable file
22
database/migrations/2022_08_27_052451_add_int_profile_pic_to_users.php
Executable file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class AddIntProfilePicToUsers extends Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->longText('discord_pfp')->after('discord_user_id')->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->dropColumn('discord_pfp');
|
||||
});
|
||||
}
|
||||
}
|
22
database/migrations/2022_09_04_133123_add_locale_to_users.php
Executable file
22
database/migrations/2022_09_04_133123_add_locale_to_users.php
Executable file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class AddLocaleToUsers extends Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->string('locale')->after('email')->default('en-US');
|
||||
});
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->dropColumn('locale');
|
||||
});
|
||||
}
|
||||
}
|
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class UpdateVacancyIntegrationNullable extends Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
Schema::table('vacancies', function (Blueprint $table) {
|
||||
$table->string('permissionGroupName')->nullable()->change();
|
||||
$table->string('discordRoleID')->nullable()->change();
|
||||
});
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
Schema::table('vacancies', function (Blueprint $table) {
|
||||
$table->string('permissionGroupName')->nullable(false)->change();
|
||||
$table->string('discordRoleID')->nullable(false)->change();
|
||||
});
|
||||
}
|
||||
}
|
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class AddDiscordRequirementToVacancies extends Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
Schema::table('vacancies', function (Blueprint $table) {
|
||||
$table->boolean('requiresDiscord')
|
||||
->default(false)
|
||||
->after('vacancyStatus');
|
||||
});
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
Schema::table('vacancies', function (Blueprint $table) {
|
||||
$table->dropColumn('requiresDiscord');
|
||||
});
|
||||
}
|
||||
}
|
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class AddRequiredAgeToVacancies extends Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
Schema::table('vacancies', function (Blueprint $table) {
|
||||
$table->integer('requiredAge')->default(16)->after('vacancyStatus');
|
||||
});
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
Schema::table('vacancies', function (Blueprint $table) {
|
||||
$table->dropColumn('requiredAge');
|
||||
});
|
||||
}
|
||||
}
|
@@ -42,6 +42,10 @@ class PermissionSeeder extends Seeder
|
||||
]
|
||||
);
|
||||
|
||||
$staff = Role::create([
|
||||
'name' => 'staff'
|
||||
]);
|
||||
|
||||
$reviewer = Role::create(
|
||||
[
|
||||
'name' => 'reviewer'
|
||||
@@ -108,15 +112,18 @@ class PermissionSeeder extends Seeder
|
||||
'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',
|
||||
$staff->givePermissionTo([
|
||||
'reviewer.viewAbsence',
|
||||
'reviewer.requestAbsence',
|
||||
'reviewer.withdrawAbsence',
|
||||
]);
|
||||
|
||||
// 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'
|
||||
]);
|
||||
|
||||
$hiringManager->givePermissionTo('appointments.*', 'applications.*', 'admin.hiring.*');
|
||||
|
||||
$admin->givePermissionTo([
|
||||
|
@@ -34,144 +34,36 @@ class UserSeeder extends Seeder
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
|
||||
|
||||
$ghostAccount = User::create([
|
||||
'uuid' => 'b741345057274a519144881927be0290', // Ghost
|
||||
'name' => 'Ghost (deleted account)',
|
||||
'email' => 'blackhole@example.com',
|
||||
'email_verified_at' => now(),
|
||||
'username' => 'ghost',
|
||||
'originalIP' => '0.0.0.0',
|
||||
'registrationIp' => '0.0.0.0',
|
||||
'currentIp' => '0.0.0.0',
|
||||
'password' => 'locked'
|
||||
])->assignRole('user'); // There can't be role-less users
|
||||
|
||||
$staffUsers = [
|
||||
|
||||
[
|
||||
'uuid' => 'd2b321b56ff1445db9d7794701983cad',
|
||||
'name' => 'Robot 1',
|
||||
'email' => 'tester1@example.com',
|
||||
'username' => 'tester1',
|
||||
'originalIP' => '99.18.146.235',
|
||||
'password' => Hash::make('password')
|
||||
],
|
||||
[
|
||||
'uuid' => 'ab22b5da02644953ace969fce85c0819',
|
||||
'name' => 'Robot 2',
|
||||
'email' => 'tester2@example.com',
|
||||
'username' => 'tester2',
|
||||
'originalIP' => '141.239.229.53',
|
||||
'password' => Hash::make('password')
|
||||
],
|
||||
[
|
||||
'uuid' => 'df38e6bf762944d3a600ded59a693ad1',
|
||||
'name' => 'Robot 3',
|
||||
'email' => 'tester3@example.com',
|
||||
'username' => 'tester3',
|
||||
'originalIP' => '25.63.20.97',
|
||||
'password' => Hash::make('password')
|
||||
],
|
||||
[
|
||||
'uuid' => '689e446484824f6bad5064e3df0aaa96',
|
||||
'name' => 'Robot 4',
|
||||
'email' => 'tester4@example.com',
|
||||
'username' => 'tester4',
|
||||
'originalIP' => '220.105.223.142',
|
||||
'password' => Hash::make('password')
|
||||
],
|
||||
[
|
||||
'uuid' => '172391f917bf418ab1c40ebc041ed5ba',
|
||||
'name' => 'Robot 5',
|
||||
'email' => 'tester5@example.com',
|
||||
'username' => 'tester5',
|
||||
'originalIP' => '224.66.76.60',
|
||||
'password' => Hash::make('password')
|
||||
],
|
||||
[
|
||||
'uuid' => '371f34dcce2a4457bf385ab9417a2345',
|
||||
'name' => 'Robot 6',
|
||||
'email' => 'tester6@example.com',
|
||||
'username' => 'tester6',
|
||||
'originalIP' => '97.113.131.0',
|
||||
'password' => Hash::make('password')
|
||||
],
|
||||
[
|
||||
'uuid' => '89aa5222855542bebe7a7780248ef5f9',
|
||||
'name' => 'Robot 7',
|
||||
'email' => 'tester7@example.com',
|
||||
'username' => 'tester7',
|
||||
'originalIP' => '15.160.137.222',
|
||||
'password' => Hash::make('password')
|
||||
],
|
||||
|
||||
];
|
||||
|
||||
$regularUsers = [
|
||||
|
||||
[
|
||||
'uuid' => '20f69f47e72f463493b5b91d1c05452f',
|
||||
'name' => 'User 1',
|
||||
'email' => 'user1@example.com',
|
||||
'username' => 'user1',
|
||||
'originalIP' => '253.25.237.78',
|
||||
'password' => Hash::make('password')
|
||||
],
|
||||
[
|
||||
'uuid' => '5f900018241e4aaba7883f2d5c5c2357',
|
||||
'name' => 'User 2',
|
||||
'email' => 'user2@example.com',
|
||||
'username' => 'user2',
|
||||
'originalIP' => '82.92.156.176',
|
||||
'password' => Hash::make('password')
|
||||
],
|
||||
[
|
||||
'uuid' => 'ba9780c3270745c6840eaabe1bf8aa14',
|
||||
'name' => 'User 3',
|
||||
'email' => 'user3@example.com',
|
||||
'username' => 'user3',
|
||||
'originalIP' => '224.123.129.17',
|
||||
'password' => Hash::make('password')
|
||||
]
|
||||
|
||||
];
|
||||
|
||||
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
|
||||
'avatarPreference' => 'gravatar',
|
||||
'userID' => $user->id
|
||||
]);
|
||||
}
|
||||
|
||||
foreach($staffUsers as $staffUser)
|
||||
{
|
||||
$user = User::create($staffUser);
|
||||
Profile::create([
|
||||
'profileShortBio' => 'Random data ' . rand(0,1000),
|
||||
'profileAboutMe' => 'Random data ' . rand(0, 1000),
|
||||
'socialLinks' => "[]",
|
||||
'avatarPreference' => 'gravatar',
|
||||
'userID' => $user->id
|
||||
]);
|
||||
|
||||
}
|
||||
|
||||
User::create([
|
||||
'uuid' => '6102256abd284dd7b68e4c96ef313734',
|
||||
$admin = User::create(([
|
||||
'uuid' => 'b741345057274a519144881927be0290', // Ghost
|
||||
'name' => 'Admin',
|
||||
'email' => 'admin@example.com',
|
||||
'email' => 'admin@webvokestudio.pt',
|
||||
'email_verified_at' => now(),
|
||||
'username' => 'admin',
|
||||
'originalIP' => '192.168.1.2',
|
||||
'password' => Hash::make('password')
|
||||
]);
|
||||
'registrationIp' => '0.0.0.0',
|
||||
'currentIp' => '0.0.0.0',
|
||||
'password' => Hash::make('admin')
|
||||
]))->assignRole('user', 'reviewer', 'hiringManager', 'admin');
|
||||
|
||||
foreach (User::all() as $user)
|
||||
{
|
||||
$user->assignRole('reviewer', 'user');
|
||||
$users = User::factory()
|
||||
->count(1500)
|
||||
->create();
|
||||
|
||||
foreach ($users as $user) {
|
||||
$user->assignRole('user');
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user