Beta version
This commit is too large to list all changes.
This commit is contained in:
@@ -27,8 +27,7 @@ class CreateProfilesTable extends Migration
|
||||
|
||||
$table->foreign('userID')
|
||||
->references('id')
|
||||
->on('users')
|
||||
->onDelete('cascade');
|
||||
->on('users');
|
||||
});
|
||||
}
|
||||
|
||||
|
@@ -31,6 +31,10 @@ class CreateApplicationsTable extends Migration
|
||||
'DENIED'
|
||||
])->default('STAGE_SUBMITTED');
|
||||
$table->timestamps();
|
||||
|
||||
$table->foreign('applicantUserID')
|
||||
->references('id')
|
||||
->on('users');
|
||||
});
|
||||
}
|
||||
|
||||
|
@@ -22,7 +22,9 @@ class CreateVotesTable extends Migration
|
||||
]);
|
||||
$table->timestamps();
|
||||
|
||||
$table->foreign('userID')->references('id')->on('users');
|
||||
$table->foreign('userID')
|
||||
->references('id')
|
||||
->on('users');
|
||||
});
|
||||
}
|
||||
|
||||
|
@@ -32,6 +32,10 @@ class CreateAppointmentsTable extends Migration
|
||||
$table->boolean('userAccepted')->default(false);
|
||||
$table->longText('meetingNotes')->nullable();
|
||||
$table->timestamps();
|
||||
|
||||
$table->foreign('applicationID')
|
||||
->references('id')
|
||||
->on('applications');
|
||||
});
|
||||
}
|
||||
|
||||
|
@@ -23,7 +23,10 @@ class CreateVacanciesTable extends Migration
|
||||
$table->integer('vacancyCount')->default(3);
|
||||
$table->timestamps();
|
||||
|
||||
$table->foreign('vacancyFormID')->references('id')->on('forms');
|
||||
$table->foreign('vacancyFormID')
|
||||
->references('id')
|
||||
->on('forms');
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
@@ -21,6 +21,10 @@ class CreateStaffProfilesTable extends Migration
|
||||
$table->dateTime('resignationDate')->nullable();
|
||||
$table->text('memberNotes')->nullable();
|
||||
$table->timestamps();
|
||||
|
||||
$table->foreign('userID')
|
||||
->references('id')
|
||||
->on('users');
|
||||
});
|
||||
}
|
||||
|
||||
|
@@ -18,6 +18,12 @@ class CreateResponsesTable extends Migration
|
||||
$table->bigInteger('responseFormID')->unsigned();
|
||||
$table->longText('responseData');
|
||||
$table->timestamps();
|
||||
|
||||
// A better way would be to link responses directly to vacancies, that subsquently have a form
|
||||
$table->foreign('responseFormID')
|
||||
->references('id')
|
||||
->on('forms');
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
@@ -25,8 +25,5 @@ class ChangeFormStructureLength extends Migration
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('forms', function (Blueprint $schema){
|
||||
$schema->string('formStructure')->change();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,110 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class CreatePermissionTables extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
$tableNames = config('permission.table_names');
|
||||
$columnNames = config('permission.column_names');
|
||||
|
||||
if (empty($tableNames)) {
|
||||
throw new \Exception('Error: config/permission.php not loaded. Run [php artisan config:clear] and try again.');
|
||||
}
|
||||
|
||||
Schema::create($tableNames['permissions'], function (Blueprint $table) {
|
||||
$table->bigIncrements('id');
|
||||
$table->string('name');
|
||||
$table->string('guard_name');
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
Schema::create($tableNames['roles'], function (Blueprint $table) {
|
||||
$table->bigIncrements('id');
|
||||
$table->string('name');
|
||||
$table->string('guard_name');
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
Schema::create($tableNames['model_has_permissions'], function (Blueprint $table) use ($tableNames, $columnNames) {
|
||||
$table->unsignedBigInteger('permission_id');
|
||||
|
||||
$table->string('model_type');
|
||||
$table->unsignedBigInteger($columnNames['model_morph_key']);
|
||||
$table->index([$columnNames['model_morph_key'], 'model_type'], 'model_has_permissions_model_id_model_type_index');
|
||||
|
||||
$table->foreign('permission_id')
|
||||
->references('id')
|
||||
->on($tableNames['permissions'])
|
||||
->onDelete('cascade');
|
||||
|
||||
$table->primary(['permission_id', $columnNames['model_morph_key'], 'model_type'],
|
||||
'model_has_permissions_permission_model_type_primary');
|
||||
});
|
||||
|
||||
Schema::create($tableNames['model_has_roles'], function (Blueprint $table) use ($tableNames, $columnNames) {
|
||||
$table->unsignedBigInteger('role_id');
|
||||
|
||||
$table->string('model_type');
|
||||
$table->unsignedBigInteger($columnNames['model_morph_key']);
|
||||
$table->index([$columnNames['model_morph_key'], 'model_type'], 'model_has_roles_model_id_model_type_index');
|
||||
|
||||
$table->foreign('role_id')
|
||||
->references('id')
|
||||
->on($tableNames['roles'])
|
||||
->onDelete('cascade');
|
||||
|
||||
$table->primary(['role_id', $columnNames['model_morph_key'], 'model_type'],
|
||||
'model_has_roles_role_model_type_primary');
|
||||
});
|
||||
|
||||
Schema::create($tableNames['role_has_permissions'], function (Blueprint $table) use ($tableNames) {
|
||||
$table->unsignedBigInteger('permission_id');
|
||||
$table->unsignedBigInteger('role_id');
|
||||
|
||||
$table->foreign('permission_id')
|
||||
->references('id')
|
||||
->on($tableNames['permissions'])
|
||||
->onDelete('cascade');
|
||||
|
||||
$table->foreign('role_id')
|
||||
->references('id')
|
||||
->on($tableNames['roles'])
|
||||
->onDelete('cascade');
|
||||
|
||||
$table->primary(['permission_id', 'role_id'], 'role_has_permissions_permission_id_role_id_primary');
|
||||
});
|
||||
|
||||
app('cache')
|
||||
->store(config('permission.cache.store') != 'default' ? config('permission.cache.store') : null)
|
||||
->forget(config('permission.cache.key'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
$tableNames = config('permission.table_names');
|
||||
|
||||
if (empty($tableNames)) {
|
||||
throw new \Exception('Error: config/permission.php not found and defaults could not be merged. Please publish the package configuration before proceeding, or drop the tables manually.');
|
||||
}
|
||||
|
||||
Schema::drop($tableNames['role_has_permissions']);
|
||||
Schema::drop($tableNames['model_has_roles']);
|
||||
Schema::drop($tableNames['model_has_permissions']);
|
||||
Schema::drop($tableNames['roles']);
|
||||
Schema::drop($tableNames['permissions']);
|
||||
}
|
||||
}
|
41
database/migrations/2020_06_08_153602_create_bans_table.php
Normal file
41
database/migrations/2020_06_08_153602_create_bans_table.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateBansTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('bans', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->bigInteger('userID')->unsigned();
|
||||
$table->string('reason');
|
||||
$table->timestamp('bannedUntil')->nullable();
|
||||
$table->string('userAgent');
|
||||
$table->bigInteger('authorUserID');
|
||||
$table->timestamps();
|
||||
|
||||
$table->foreign('userID')
|
||||
->references('id')
|
||||
->on('users');
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('bans');
|
||||
}
|
||||
}
|
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateCommentsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('comments', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->bigInteger('authorID')->unsigned();
|
||||
$table->bigInteger('applicationID')->unsigned();
|
||||
$table->mediumText('text');
|
||||
$table->timestamps();
|
||||
|
||||
$table->foreign('authorID')
|
||||
->references('id')
|
||||
->on('users');
|
||||
|
||||
$table->foreign('applicationID')
|
||||
->references('id')
|
||||
->on('applications');
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('comments');
|
||||
}
|
||||
}
|
36
database/migrations/2020_06_25_093708_create_jobs_table.php
Normal file
36
database/migrations/2020_06_25_093708_create_jobs_table.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class CreateJobsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('jobs', function (Blueprint $table) {
|
||||
$table->bigIncrements('id');
|
||||
$table->string('queue')->index();
|
||||
$table->longText('payload');
|
||||
$table->unsignedTinyInteger('attempts');
|
||||
$table->unsignedInteger('reserved_at')->nullable();
|
||||
$table->unsignedInteger('available_at');
|
||||
$table->unsignedInteger('created_at');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('jobs');
|
||||
}
|
||||
}
|
@@ -11,6 +11,7 @@ class DatabaseSeeder extends Seeder
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
// $this->call(UserSeeder::class);
|
||||
$this->call(PermissionSeeder::class);
|
||||
$this->call(UserSeeder::class);
|
||||
}
|
||||
}
|
||||
|
98
database/seeds/PermissionSeeder.php
Normal file
98
database/seeds/PermissionSeeder.php
Normal file
@@ -0,0 +1,98 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
use Spatie\Permission\Models\Permission;
|
||||
use Spatie\Permission\Models\Role;
|
||||
|
||||
class PermissionSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
app()[\Spatie\Permission\PermissionRegistrar::class]->forgetCachedPermissions();
|
||||
|
||||
//
|
||||
$user = Role::create(
|
||||
[
|
||||
'name' => 'user'
|
||||
]
|
||||
);
|
||||
|
||||
$reviewer = Role::create(
|
||||
[
|
||||
'name' => 'reviewer'
|
||||
]
|
||||
);
|
||||
|
||||
$hiringManager = Role::create(
|
||||
[
|
||||
'name' => 'hiringManager'
|
||||
]
|
||||
);
|
||||
|
||||
$admin = Role::create([
|
||||
'name' => 'admin'
|
||||
]);
|
||||
|
||||
// Spatie wildcard permissions (same concept of MC permissions)
|
||||
|
||||
Permission::create(['name' => 'applications.submit']);
|
||||
Permission::create(['name' => 'applications.stages.deny']);
|
||||
Permission::create(['name' => 'applications.stages.approve']);
|
||||
Permission::create(['name' => 'applications.view.all']);
|
||||
Permission::create(['name' => 'applications.view.own']);
|
||||
Permission::create(['name' => 'applications.vote']);
|
||||
Permission::create(['name' => 'appointments.schedule']);
|
||||
Permission::create(['name' => 'appointments.schedule.edit']);
|
||||
Permission::create(['name' => 'appointments.schedule.cancel']);
|
||||
Permission::create(['name' => 'applications.*']);
|
||||
Permission::create(['name' => 'appointments.*']);
|
||||
|
||||
Permission::create(['name' => 'profiles.view.others']);
|
||||
Permission::create(['name' => 'profiles.edit.others']);
|
||||
|
||||
Permission::create(['name' => 'admin.userlist']);
|
||||
Permission::create(['name' => 'admin.stafflist']);
|
||||
Permission::create(['name' => 'admin.hiring.forms']);
|
||||
Permission::create(['name' => 'admin.hiring.formbuilder']);
|
||||
Permission::create(['name' => 'admin.hiring.vacancy']);
|
||||
Permission::create(['name' => 'admin.hiring.vacancy.edit,delete']);
|
||||
Permission::create(['name' => 'admin.notificationsettings']);
|
||||
Permission::create(['name' => 'admin.notificationsettings.edit']);
|
||||
Permission::create(['name' => 'admin.hiring.*']);
|
||||
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'
|
||||
]);
|
||||
|
||||
// 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([
|
||||
'appointments.*',
|
||||
'admin.userlist',
|
||||
'admin.stafflist',
|
||||
'admin.hiring.*',
|
||||
'admin.notificationsettings.*',
|
||||
'profiles.view.others',
|
||||
'profiles.edit.others',
|
||||
'admin.maintenance.logs.view'
|
||||
]);
|
||||
}
|
||||
}
|
146
database/seeds/UserSeeder.php
Normal file
146
database/seeds/UserSeeder.php
Normal file
@@ -0,0 +1,146 @@
|
||||
<?php
|
||||
|
||||
use App\Profile;
|
||||
use App\User;
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
|
||||
class UserSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
$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',
|
||||
'name' => 'Admin',
|
||||
'email' => 'admin@example.com',
|
||||
'username' => 'admin',
|
||||
'originalIP' => '192.168.1.2',
|
||||
'password' => Hash::make('password')
|
||||
]);
|
||||
|
||||
foreach (User::all() as $user)
|
||||
{
|
||||
$user->assignRole('reviewer', 'user');
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user