Created a membership approval token repository and required token table & model

This commit is contained in:
2022-02-15 16:36:54 +00:00
parent 6039574d79
commit 8d762c5dca
5 changed files with 322 additions and 0 deletions

View 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 Membership Approvals table migration
* Manages requests for organisation membership join requests.
* Version 1.0.0.
*
* @author Craig Williams (https://avsdev.uk)
*/
class OrganisationMembershipApprovalsTable extends Migration
{
/**
* {@inheritdoc}
*/
public function up()
{
if (!$this->schema->hasTable('organisation_membership_approvals')) {
$this->schema->create('organisation_membership_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()->nullable();
$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_membership_approvals');
}
}

View File

@@ -0,0 +1,64 @@
<?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 Illuminate\Database\Capsule\Manager as DB;
use UserFrosting\Sprinkle\Core\Database\Migration;
/**
* Organisation Membership Approvals table migration
* Manages requests for organisation membership join requests.
* Version 1.0.0.
*
* @author Craig Williams (https://avsdev.uk)
*/
class UpdateOrganisationMembershipApprovalsTable extends Migration
{
/**
* {@inheritdoc}
*/
public function up()
{
if ($this->schema->hasTable('organisation_membership_approvals')) {
DB::table('organisation_membership_approvals')->delete();
$this->schema->table('organisation_membership_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()
{
if ($this->schema->hasTable('organisation_membership_approvals')) {
DB::table('organisation_membership_approvals')->delete();
$this->schema->table('organisation_membership_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');
});
}
}
}