mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-19 20:43:56 +00:00
59 lines
1.6 KiB
PHP
59 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace App\Classes\Modules\Segments\ControllersLogic;
|
|
|
|
|
|
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
|
use App\Classes\Modules\Segments\Standards\Rules\CanFetchSegment;
|
|
use App\Classes\Modules\Segments\Services\FetchesSegment;
|
|
use App\Http\Resources\SegmentResource;
|
|
use Illuminate\Http\JsonResponse;
|
|
use Illuminate\Http\Request;
|
|
|
|
class FetchSegmentLogic extends AbstractControllerLogic
|
|
{
|
|
|
|
/**
|
|
* @return array
|
|
*/
|
|
protected function notification():array {
|
|
return [
|
|
'title' => 'Retrieved Segment',
|
|
'message' => 'You have successfully retrieved a segment'
|
|
];
|
|
}
|
|
|
|
/** @var CanFetchSegment */
|
|
private $canFetchSegment;
|
|
|
|
/** @var FetchesSegment */
|
|
private $fetchesSegment;
|
|
|
|
/**
|
|
* FetchSegmentLogic constructor.
|
|
* @param CanFetchSegment $canFetchSegment
|
|
* @param FetchesSegment $fetchesSegment
|
|
*/
|
|
public function __construct(CanFetchSegment $canFetchSegment, FetchesSegment $fetchesSegment)
|
|
{
|
|
$this->canFetchSegment = $canFetchSegment;
|
|
$this->fetchesSegment = $fetchesSegment;
|
|
}
|
|
|
|
/**
|
|
* @param Request $request
|
|
* @return JsonResponse
|
|
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
|
* @throws \App\Classes\Exceptions\RequestValidationException
|
|
*/
|
|
public function logic(Request $request) : JsonResponse
|
|
{
|
|
$this->canFetchSegment->passes();
|
|
|
|
$query = $this->fetchesSegment->execute(['id' => $request->route('id')]);
|
|
|
|
return $this->resourceResponse(new SegmentResource($query));
|
|
|
|
}
|
|
|
|
} |