Refactored organisation approval class to a base model which will soon be included in a membership approval class
This commit is contained in:
111
src/Database/Models/BaseOrganisationApproval.php
Normal file
111
src/Database/Models/BaseOrganisationApproval.php
Normal file
@@ -0,0 +1,111 @@
|
|||||||
|
<?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\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Capsule\Manager as DB;
|
||||||
|
use UserFrosting\Sprinkle\Core\Database\Models\Model;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Base organisation approval class.
|
||||||
|
*
|
||||||
|
* Represents a pending approval request which is tied to a user/organisation pair (membership, registration etc)
|
||||||
|
*
|
||||||
|
* @author Craig Williams (https://avsdev.uk)
|
||||||
|
*
|
||||||
|
* @property int $requester_id
|
||||||
|
* @property int $organisation_id
|
||||||
|
* @property hash $token
|
||||||
|
* @property bool $completed
|
||||||
|
* @property datetime $expires_at
|
||||||
|
* @property datetime $completed_at
|
||||||
|
* @property int $approver_id
|
||||||
|
*/
|
||||||
|
|
||||||
|
class BaseOrganisationApproval extends Model
|
||||||
|
{
|
||||||
|
protected $fillable = [
|
||||||
|
'requester_id',
|
||||||
|
'organisation_id',
|
||||||
|
'hash',
|
||||||
|
'completed',
|
||||||
|
'expires_at',
|
||||||
|
'completed_at',
|
||||||
|
'approver_id,'
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var bool Enable timestamps for Verifications.
|
||||||
|
*/
|
||||||
|
public $timestamps = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string Stores the raw (unhashed) token when created, so that it can be emailed out to the user. NOT persisted.
|
||||||
|
*/
|
||||||
|
protected $token;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getToken()
|
||||||
|
{
|
||||||
|
return $this->token;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $value
|
||||||
|
*
|
||||||
|
* @return self
|
||||||
|
*/
|
||||||
|
public function setToken($value)
|
||||||
|
{
|
||||||
|
$this->token = $value;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the user associated with this request of this approval.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||||
|
*/
|
||||||
|
public function requester()
|
||||||
|
{
|
||||||
|
/** @var \UserFrosting\Sprinkle\Core\Util\ClassMapper $classMapper */
|
||||||
|
$classMapper = static::$ci->classMapper;
|
||||||
|
|
||||||
|
return $this->belongsTo($classMapper->getClassMapping('user'), 'requester_id');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the organisation associated with this approval request.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Database\Eloquent\Relations\belongsTo
|
||||||
|
*/
|
||||||
|
public function organisation()
|
||||||
|
{
|
||||||
|
/** @var \UserFrosting\Sprinkle\Core\Util\ClassMapper $classMapper */
|
||||||
|
$classMapper = static::$ci->classMapper;
|
||||||
|
|
||||||
|
return $this->belongsTo($classMapper->getClassMapping('organisation'), 'organisation_id');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the user associated with this approval or rejection of this request.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Database\Eloquent\Relations\belongsTo
|
||||||
|
*/
|
||||||
|
public function approver()
|
||||||
|
{
|
||||||
|
/** @var \UserFrosting\Sprinkle\Core\Util\ClassMapper $classMapper */
|
||||||
|
$classMapper = static::$ci->classMapper;
|
||||||
|
|
||||||
|
return $this->belongsTo($classMapper->getClassMapping('user'), 'approver_id');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -10,7 +10,7 @@
|
|||||||
namespace UserFrosting\Sprinkle\Organisations\Database\Models;
|
namespace UserFrosting\Sprinkle\Organisations\Database\Models;
|
||||||
|
|
||||||
use Illuminate\Database\Capsule\Manager as DB;
|
use Illuminate\Database\Capsule\Manager as DB;
|
||||||
use UserFrosting\Sprinkle\Core\Database\Models\Model;
|
use UserFrosting\Sprinkle\Organisations\Database\Models\BaseOrganisationApproval;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Organisation Approval Class.
|
* Organisation Approval Class.
|
||||||
@@ -18,99 +18,12 @@ use UserFrosting\Sprinkle\Core\Database\Models\Model;
|
|||||||
* Represents a pending organisation approval request.
|
* Represents a pending organisation approval request.
|
||||||
*
|
*
|
||||||
* @author Craig Williams (https://avsdev.uk)
|
* @author Craig Williams (https://avsdev.uk)
|
||||||
*
|
|
||||||
* @property int $requester_id
|
|
||||||
* @property int $organisation_id
|
|
||||||
* @property hash $token
|
|
||||||
* @property bool $completed
|
|
||||||
* @property datetime $expires_at
|
|
||||||
* @property datetime $completed_at
|
|
||||||
* @property int $approver_id
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class OrganisationApproval extends Model
|
class OrganisationApproval extends BaseOrganisationApproval
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var string The name of the table for the current model.
|
* @var string The name of the table for the current model.
|
||||||
*/
|
*/
|
||||||
protected $table = 'organisation_approvals';
|
protected $table = 'organisation_approvals';
|
||||||
|
|
||||||
protected $fillable = [
|
|
||||||
'requester_id',
|
|
||||||
'organisation_id',
|
|
||||||
'hash',
|
|
||||||
'completed',
|
|
||||||
'expires_at',
|
|
||||||
'completed_at',
|
|
||||||
'approver_id,'
|
|
||||||
];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var bool Enable timestamps for Verifications.
|
|
||||||
*/
|
|
||||||
public $timestamps = true;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var string Stores the raw (unhashed) token when created, so that it can be emailed out to the user. NOT persisted.
|
|
||||||
*/
|
|
||||||
protected $token;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getToken()
|
|
||||||
{
|
|
||||||
return $this->token;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param string $value
|
|
||||||
*
|
|
||||||
* @return self
|
|
||||||
*/
|
|
||||||
public function setToken($value)
|
|
||||||
{
|
|
||||||
$this->token = $value;
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the user associated with this request of this approval.
|
|
||||||
*
|
|
||||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
|
||||||
*/
|
|
||||||
public function requester()
|
|
||||||
{
|
|
||||||
/** @var \UserFrosting\Sprinkle\Core\Util\ClassMapper $classMapper */
|
|
||||||
$classMapper = static::$ci->classMapper;
|
|
||||||
|
|
||||||
return $this->belongsTo($classMapper->getClassMapping('user'), 'requester_id');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the organisation associated with this approval request.
|
|
||||||
*
|
|
||||||
* @return \Illuminate\Database\Eloquent\Relations\belongsTo
|
|
||||||
*/
|
|
||||||
public function organisation()
|
|
||||||
{
|
|
||||||
/** @var \UserFrosting\Sprinkle\Core\Util\ClassMapper $classMapper */
|
|
||||||
$classMapper = static::$ci->classMapper;
|
|
||||||
|
|
||||||
return $this->belongsTo($classMapper->getClassMapping('organisation'), 'organisation_id');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the user associated with this approval or rejection of this request.
|
|
||||||
*
|
|
||||||
* @return \Illuminate\Database\Eloquent\Relations\belongsTo
|
|
||||||
*/
|
|
||||||
public function approver()
|
|
||||||
{
|
|
||||||
/** @var \UserFrosting\Sprinkle\Core\Util\ClassMapper $classMapper */
|
|
||||||
$classMapper = static::$ci->classMapper;
|
|
||||||
|
|
||||||
return $this->belongsTo($classMapper->getClassMapping('user'), 'approver_id');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user