Files
shipping-portal/app/Classes/Modules/Segments/ControllersLogic/FetchSegmentLogic.php
edmondlang 05b1aedda5 Merge branch 'admin-settings-ui' of gitlab.com:CIEFWorldwideSdnBhd/shipping-portal into development
# 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
2022-02-09 21:09:17 +08:00

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));
}
}