mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal.git
synced 2026-08-20 21:14:04 +00:00
05b1aedda5
# Conflicts: # app/Classes/Modules/Announcements/DataTransferObjects/AnnouncementObject.php # app/Classes/Modules/Segments/ControllersLogic/CreateSegmentLogic.php # app/Classes/Modules/Segments/ControllersLogic/DeleteSegmentLogic.php # app/Classes/Modules/Segments/DataTransferObjects/SegmentObject.php # app/Classes/Modules/Segments/Services/CreatesSegment.php # app/Classes/Modules/Segments/Standards/Rules/CanCreateSegment.php # app/Classes/Modules/Segments/Standards/Rules/CanDeleteSegment.php # app/Classes/Modules/Segments/Standards/Validators/SegmentValidation.php # app/Http/Controllers/Announcements/AssignAnnouncementToSegmentController.php # app/Http/Controllers/Announcements/ListAnnouncementsController.php # app/Http/Controllers/Announcements/RemoveSegmentFromAnnouncementController.php # app/Http/Controllers/Announcements/UpdateAnnouncementController.php # app/Http/Controllers/Segments/CreateSegmentController.php # app/Http/Controllers/Segments/DeleteSegmentController.php # routes/announcement.php # routes/api.php # routes/segment.php # routes/web.php
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));
|
|
|
|
}
|
|
|
|
} |