mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-19 20:43:56 +00:00
61 lines
1.4 KiB
PHP
61 lines
1.4 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;
|
|
use Illuminate\Support\Facades\Auth;
|
|
use Illuminate\Support\Facades\Log;
|
|
|
|
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($object): bool
|
|
{
|
|
// TODO Set Authorization rules
|
|
/** @var \App\Models\User $user */
|
|
$user = Auth::user();
|
|
|
|
if (!$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;
|
|
}
|
|
}
|