mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-19 04:23:55 +00:00
8b01421be7
-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
55 lines
1.2 KiB
PHP
55 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Classes\Modules\Segments\Standards\Rules;
|
|
|
|
use App\Classes\General\Abstracts\AbstractRule;
|
|
use App\Classes\Modules\Segments\DataTransferObjects\SegmentObject;
|
|
use App\Classes\Modules\Segments\Standards\Validators\SegmentValidation;
|
|
|
|
class CanCreateSegment extends AbstractRule
|
|
{
|
|
|
|
/** @var SegmentValidation */
|
|
private $segmentValidation;
|
|
|
|
/**
|
|
* CanCreateSegment constructor.
|
|
* @param SegmentValidation $segmentValidation
|
|
*/
|
|
public function __construct(SegmentValidation $segmentValidation)
|
|
{
|
|
$this->segmentValidation = $segmentValidation;
|
|
}
|
|
|
|
/**
|
|
* @return bool
|
|
*/
|
|
protected function authorized(): bool
|
|
{
|
|
// TODO Set Authorization rules
|
|
if (!\Auth::user()->can('add segment')) {
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* @param SegmentObject $object
|
|
* @return bool
|
|
* @throws \App\Classes\Exceptions\RequestValidationException
|
|
*/
|
|
protected function validators($object): bool
|
|
{
|
|
return $this->segmentValidation->validate($object);
|
|
}
|
|
|
|
/**
|
|
* @param SegmentObject $object
|
|
* @return bool
|
|
*/
|
|
protected function criteria($object): bool
|
|
{
|
|
return true;
|
|
}
|
|
} |