mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-19 04:23:55 +00:00
55 lines
1.3 KiB
PHP
55 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Classes\Modules\Milestones\Standards\Rules;
|
|
|
|
use App\Classes\General\Abstracts\AbstractRule;
|
|
use App\Classes\Modules\Milestones\Standards\Validators\MilestoneValidation;
|
|
use App\Classes\Modules\Milestones\DataTransferObjects\MilestoneObject;
|
|
use Illuminate\Support\Facades\Auth;
|
|
|
|
class CanCreateMilestone extends AbstractRule
|
|
{
|
|
|
|
/** @var MilestoneValidation */
|
|
private $milestoneValidation;
|
|
|
|
/**
|
|
* CanCreateMilestone constructor.
|
|
* @param MilestoneValidation $milestoneValidation
|
|
*/
|
|
public function __construct(MilestoneValidation $milestoneValidation)
|
|
{
|
|
$this->milestoneValidation = $milestoneValidation;
|
|
}
|
|
|
|
/**
|
|
* @return bool
|
|
*/
|
|
protected function authorized(): bool
|
|
{
|
|
if (!Auth::user()->can('add milestone')) {
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* @param MilestoneObject $object
|
|
* @return bool
|
|
* @throws \App\Classes\Exceptions\RequestValidationException
|
|
*/
|
|
protected function validators($object): bool
|
|
{
|
|
return $this->milestoneValidation->validate($object, 'POST');
|
|
}
|
|
|
|
/**
|
|
* @param MilestoneObject $object
|
|
* @return bool
|
|
*/
|
|
protected function criteria($object): bool
|
|
{
|
|
return true;
|
|
}
|
|
}
|