mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal.git
synced 2026-08-20 13:04:48 +00:00
66 lines
1.6 KiB
PHP
66 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace App\Classes\Modules\HelpMenu\Standards\Rules;
|
|
|
|
|
|
use App\Classes\General\Abstracts\AbstractRule;
|
|
use App\Classes\ValueObjects\Constants\RoleTypes;
|
|
use App\Classes\Modules\HelpMenu\Standards\Validators\FeedbackUrlValidation;
|
|
use App\Classes\Modules\HelpMenu\DataTransferObjects\GenerateFeedbackUrlObject;
|
|
use Illuminate\Support\Facades\Log;
|
|
|
|
class CanGenerateFeedbackUrl extends AbstractRule
|
|
{
|
|
|
|
/** @var FeedbackUrlValidation */
|
|
private $feedbackUrlValidation;
|
|
|
|
/**
|
|
* CanGenerateFeedbackUrl constructor.
|
|
* @param FeedbackUrlValidation $feedbackUrlValidation
|
|
*/
|
|
public function __construct(FeedbackUrlValidation $feedbackUrlValidation)
|
|
{
|
|
$this->feedbackUrlValidation = $feedbackUrlValidation;
|
|
}
|
|
|
|
/**
|
|
* @return bool
|
|
*/
|
|
protected function authorized($object): bool
|
|
{
|
|
$user = Auth()->user();
|
|
if($user){
|
|
$roleToCheck = Auth()->user()->type;
|
|
if (in_array($roleToCheck, RoleTypes::ADMIN_ROLES)) {
|
|
return true;
|
|
}
|
|
}
|
|
else if($object->getApiKey()){
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
/**
|
|
* @param GenerateFeedbackUrlObject $object
|
|
* @return bool
|
|
* @throws \App\Classes\Exceptions\RequestValidationException
|
|
*/
|
|
protected function validators($object): bool
|
|
{
|
|
return $this->feedbackUrlValidation->validate($object);
|
|
}
|
|
|
|
/**
|
|
* @param $object
|
|
* @return bool
|
|
*/
|
|
protected function criteria($object): bool
|
|
{
|
|
return true;
|
|
}
|
|
|
|
}
|