mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal.git
synced 2026-08-19 04:24:12 +00:00
67 lines
2.0 KiB
PHP
67 lines
2.0 KiB
PHP
<?php
|
|
|
|
namespace App\Classes\Modules\ContainerPackingLists\ControllersLogic;
|
|
|
|
|
|
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
|
use App\Classes\Modules\ContainerPackingLists\Services\FetchesContainerPackingList;
|
|
use App\Classes\Modules\ContainerPackingLists\Standards\Rules\CanFetchContainerPackingList;
|
|
use App\Http\Resources\ContainerPackingListResource;
|
|
use ErrorException;
|
|
use Illuminate\Http\JsonResponse;
|
|
use Illuminate\Http\Request;
|
|
|
|
class FetchContainerPackingListLogic extends AbstractControllerLogic
|
|
{
|
|
|
|
/**
|
|
* @return array
|
|
*/
|
|
protected function notification():array {
|
|
return [
|
|
'title' => 'Retrieved ContainerPackingList',
|
|
'message' => 'You have successfully retrieved a ContainerPackingList'
|
|
];
|
|
}
|
|
|
|
/** @var CanFetchContainerPackingList */
|
|
private $canFetchContainerPackingList;
|
|
|
|
/** @var FetchesContainerPackingList */
|
|
private $fetchesContainerPackingList;
|
|
|
|
/**
|
|
* FetchContainerPackingListControllersLogic constructor.
|
|
* @param CanFetchContainerPackingList $canFetchContainerPackingList
|
|
* @param FetchesContainerPackingList $fetchesContainerPackingList
|
|
*/
|
|
public function __construct(CanFetchContainerPackingList $canFetchContainerPackingList, FetchesContainerPackingList $fetchesContainerPackingList)
|
|
{
|
|
$this->canFetchContainerPackingList = $canFetchContainerPackingList;
|
|
$this->fetchesContainerPackingList = $fetchesContainerPackingList;
|
|
}
|
|
|
|
|
|
/**
|
|
* @param Request $request
|
|
* @return JsonResponse
|
|
* @throws ErrorException
|
|
*/
|
|
public function logic(Request $request) : JsonResponse
|
|
{
|
|
try {
|
|
|
|
$this->canFetchContainerPackingList->passes();
|
|
|
|
$query = $this->fetchesContainerPackingList->execute(['id' => $request->route('id')]);
|
|
|
|
return $this->resourceResponse(new ContainerPackingListResource($query));
|
|
|
|
} catch (\Exception $exception){
|
|
throw new ErrorException($exception->getMessage(), $exception->getCode());
|
|
}
|
|
|
|
}
|
|
|
|
}
|