Revamped the organisation approvals process & refactored some files

This commit is contained in:
2022-02-15 15:26:56 +00:00
parent e029728d69
commit cd8a16f4a8
10 changed files with 643 additions and 668 deletions

View File

@@ -0,0 +1,68 @@
<?php
/*
* AVSDev UF Organisations (https://avsdev.uk)
*
* @link https://git.avsdev.uk/avsdev/sprinkle-organisations
* @license https://git.avsdev.uk/avsdev/sprinkle-organisations/blob/master/LICENSE.md (LGPL-3.0 License)
*/
namespace UserFrosting\Sprinkle\Organisations\Database\Migrations\v003;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Capsule\Manager as DB;
use UserFrosting\Sprinkle\Core\Database\Migration;
/**
* Organisations approvals table migration
* Drops the requester_id (moved to organisations as registrant_id) and organisation_id in favor of an owner_id.
* Version 1.0.0.
*
* @author Craig Williams (https://avsdev.uk)
*/
class UpdateOrganisationApprovalsTable extends Migration
{
/**
* {@inheritdoc}
*/
public static $dependencies = [
'\UserFrosting\Sprinkle\Organisations\Database\Migrations\v002\UpdateOrganisationApprovalsTable',
];
/**
* {@inheritdoc}
*/
public function up()
{
if ($this->schema->hasTable('organisation_approvals')) {
DB::table('organisation_approvals')->delete();
$this->schema->table('organisation_approvals', function (Blueprint $table) {
$table->dropForeign(['requester_id']);
$table->dropForeign(['organisation_id']);
$table->dropIndex(['requester_id']);
$table->dropColumn(['requester_id']);
$table->dropColumn(['organisation_id']);
$table->integer('owner_id')->unsigned();
$table->index('owner_id');
});
}
}
/**
* {@inheritdoc}
*/
public function down()
{
DB::table('organisation_approvals')->delete();
$this->schema->table('organisation_approvals', function (Blueprint $table) {
$table->dropIndex(['owner_id']);
$table->dropColumn('owner_id')->unsigned();
$table->integer('requester_id')->unsigned();
$table->integer('organisation_id')->unsigned();
$table->index('requester_id');
$table->foreign('requester_id')->references('id')->on('users');
$table->foreign('organisation_id')->references('id')->on('organisations');
});
}
}

View File

@@ -0,0 +1,55 @@
<?php
/*
* AVSDev UF Organisations (https://avsdev.uk)
*
* @link https://git.avsdev.uk/avsdev/sprinkle-organisations
* @license https://git.avsdev.uk/avsdev/sprinkle-organisations/blob/master/LICENSE.md (LGPL-3.0 License)
*/
namespace UserFrosting\Sprinkle\Organisations\Database\Migrations\v003;
use Illuminate\Database\Schema\Blueprint;
use UserFrosting\Sprinkle\Organisations\Database\Models\Organisation;
use UserFrosting\Sprinkle\Core\Database\Migration;
use UserFrosting\Sprinkle\Core\Facades\Seeder;
/**
* Organisations table migration
* Adds a `registrant_id` column to the `organisations` table
* Version 1.0.0.
*
* @author Craig Williams (https://avsdev.uk)
*/
class UpdateOrganisationsTable extends Migration
{
/**
* {@inheritdoc}
*/
public static $dependencies = [
'\UserFrosting\Sprinkle\Account\Database\Migrations\v400\UsersTable',
'\UserFrosting\Sprinkle\Organisations\Database\Migrations\v002\UpdateOrganisationsTable',
];
/**
* {@inheritdoc}
*/
public function up()
{
if ($this->schema->hasTable('organisations')) {
$this->schema->table('organisations', function (Blueprint $table) {
$table->integer('registrant_id')->unsigned()->nullable();
});
}
}
/**
* {@inheritdoc}
*/
public function down()
{
$this->schema->table('organisations', function (Blueprint $table) {
$table->dropColumn('registrant_id');
});
}
}