Files
exchange-2.0/app/Classes/Modules/SegmentConstants/Standards/Rules/CanCreateSegmentConstant.php
T
CheeSiong 8b01421be7 -Update Non Standard Segment Logic Class
-Update Non Segment Constant Service Class
-Create Non Standard Segment Constant Logic Class
-Update Non Standard Segment Constant Logic Class
-Delete Non Standard Segment Logic Class
2020-11-17 12:08:10 +08:00

55 lines
1.4 KiB
PHP

<?php
namespace App\Classes\Modules\SegmentConstants\Standards\Rules;
use App\Classes\General\Abstracts\AbstractRule;
use App\Classes\Modules\SegmentConstants\DataTransferObjects\SegmentObject;
use App\Classes\Modules\SegmentConstants\Standards\Validators\SegmentConstantValidation;
class CanCreateSegmentConstant extends AbstractRule
{
/** @var SegmentConstantValidation */
private $segmentConstantValidation;
/**
* CanCreateSegmentConstant constructor.
* @param SegmentConstantValidation $segmentConstantValidation
*/
public function __construct(SegmentConstantValidation $segmentConstantValidation)
{
$this->segmentConstantValidation = $segmentConstantValidation;
}
/**
* @return bool
*/
protected function authorized(): bool
{
// TODO Set Authorization rules
if (!\Auth::user()->can('add segment_constant')) {
return false;
}
return true;
}
/**
* @param SegmentObject $object
* @return bool
* @throws \App\Classes\Exceptions\RequestValidationException
*/
protected function validators($object): bool
{
return $this->segmentConstantValidation->validate($object, 'POST');
}
/**
* @param SegmentObject $object
* @return bool
*/
protected function criteria($object): bool
{
return true;
}
}