mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal.git
synced 2026-08-19 04:24:12 +00:00
59 lines
1.4 KiB
PHP
59 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\Classes\Modules\Transactions\Standards\Rules;
|
|
|
|
|
|
use App\Classes\General\Abstracts\AbstractRule;
|
|
use App\Classes\Modules\Transactions\DataTransferObjects\WaiveTransactionObject;
|
|
use App\Classes\Modules\Transactions\Standards\Validators\WaiveTransactionValidation;
|
|
use App\Classes\ValueObjects\Constants\RoleTypes;
|
|
|
|
class CanWaiveTransaction extends AbstractRule
|
|
{
|
|
|
|
/** @var WaiveTransactionValidation */
|
|
private $waiveTransactionValidation;
|
|
|
|
|
|
public function __construct(WaiveTransactionValidation $waiveTransactionValidation)
|
|
{
|
|
$this->waiveTransactionValidation = $waiveTransactionValidation;
|
|
}
|
|
|
|
/**
|
|
* @return bool
|
|
*/
|
|
protected function authorized($object): bool
|
|
{
|
|
$user = Auth()->user();
|
|
if($user){
|
|
$roleToCheck = Auth()->user()->type;
|
|
if (in_array($roleToCheck, RoleTypes::ADMIN_ROLES)) {
|
|
return true;
|
|
}
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
/**
|
|
* @param WaiveTransactionObject $object
|
|
* @return bool
|
|
* @throws \App\Classes\Exceptions\RequestValidationException
|
|
*/
|
|
protected function validators($object): bool
|
|
{
|
|
return $this->waiveTransactionValidation->validate($object);
|
|
}
|
|
|
|
/**
|
|
* @param $object
|
|
* @return bool
|
|
*/
|
|
protected function criteria($object): bool
|
|
{
|
|
return true;
|
|
}
|
|
|
|
}
|