Organisation registration process implemented with configurable approval workflow
This commit is contained in:
61
src/Database/Migrations/v001/OrganisationApprovalsTable.php
Normal file
61
src/Database/Migrations/v001/OrganisationApprovalsTable.php
Normal file
@@ -0,0 +1,61 @@
|
||||
<?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\v001;
|
||||
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use UserFrosting\Sprinkle\Core\Database\Migration;
|
||||
|
||||
/**
|
||||
* Organisation Approvals table migration
|
||||
* Manages requests for organisation approvals.
|
||||
* Version 1.0.0.
|
||||
*
|
||||
* @author Craig Williams (https://avsdev.uk)
|
||||
*/
|
||||
class OrganisationApprovalsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
if (!$this->schema->hasTable('organisation_approvals')) {
|
||||
$this->schema->create('organisation_approvals', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('requester_id')->unsigned();
|
||||
$table->integer('organisation_id')->unsigned();
|
||||
$table->string('hash');
|
||||
$table->boolean('completed')->default(0);
|
||||
$table->timestamp('expires_at')->nullable();
|
||||
$table->timestamp('completed_at')->nullable();
|
||||
$table->integer('approver_id')->unsigned();
|
||||
$table->timestamps();
|
||||
|
||||
$table->engine = 'InnoDB';
|
||||
$table->collation = 'utf8_unicode_ci';
|
||||
$table->charset = 'utf8';
|
||||
$table->foreign('requester_id')->references('id')->on('users');
|
||||
$table->foreign('approver_id')->references('id')->on('users');
|
||||
$table->foreign('organisation_id')->references('id')->on('organisations');
|
||||
$table->index('requester_id');
|
||||
$table->index('approver_id');
|
||||
$table->index('hash');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
$this->schema->drop('organisation_approvals');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
<?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\v002;
|
||||
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use UserFrosting\Sprinkle\Core\Database\Migration;
|
||||
|
||||
/**
|
||||
* Organisations approvals table migration
|
||||
* Make the approver_id nullable
|
||||
* Version 1.0.0.
|
||||
*
|
||||
* @author Craig Williams (https://avsdev.uk)
|
||||
*/
|
||||
class UpdateOrganisationApprovalsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $dependencies = [
|
||||
'\UserFrosting\Sprinkle\Organisations\Database\Migrations\v001\OrganisationApprovalsTable',
|
||||
];
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
if ($this->schema->hasTable('organisation_approvals')) {
|
||||
$this->schema->table('organisation_approvals', function (Blueprint $table) {
|
||||
$table->integer('approver_id')->unsigned()->nullable()->change();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
$this->schema->table('organisations', function (Blueprint $table) {
|
||||
$table->integer('approver_id')->unsigned()->change();
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user