mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal.git
synced 2026-08-19 04:24:12 +00:00
59 lines
1.2 KiB
PHP
59 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 CanUpdateSegment extends AbstractRule
|
|
{
|
|
|
|
/** @var SegmentValidation */
|
|
private $segmentValidation;
|
|
|
|
|
|
/**
|
|
* CanUpdateSegment 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('edit 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;
|
|
}
|
|
|
|
} |