WIP - Order steps & remaining APIs

This commit is contained in:
Fairuz
2021-07-23 15:07:05 +08:00
parent d7131dd5f8
commit 1fe25476ce
19 changed files with 2914 additions and 1085 deletions
@@ -0,0 +1,66 @@
<?php
namespace App\Classes\Modules\PackingLists\ControllersLogic;
use App\Classes\General\Abstracts\AbstractControllerLogic;
use App\Classes\Modules\PackingLists\Services\FetchesPackingList;
use App\Classes\Modules\PackingLists\Standards\Rules\CanFetchPackingList;
use App\Http\Resources\PackingListResource;
use ErrorException;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
class FetchContainerPackingList extends AbstractControllerLogic
{
/**
* @return array
*/
protected function notification():array {
return [
'title' => 'Retrieved PackingList',
'message' => 'You have successfully retrieved a PackingList'
];
}
/** @var CanFetchPackingList */
private $canFetchPackingList;
/** @var FetchesPackingList */
private $fetchesPackingList;
/**
* FetchPackingListControllersLogic constructor.
* @param CanFetchPackingList $canFetchPackingList
* @param FetchesPackingList $fetchesPackingList
*/
public function __construct(CanFetchPackingList $canFetchPackingList, FetchesPackingList $fetchesPackingList)
{
$this->canFetchPackingList = $canFetchPackingList;
$this->fetchesPackingList = $fetchesPackingList;
}
/**
* @param Request $request
* @return JsonResponse
* @throws ErrorException
*/
public function logic(Request $request) : JsonResponse
{
try {
$this->canFetchPackingList->passes();
$query = $this->fetchesPackingList->execute(['id' => $request->route('id')]);
return $this->resourceResponse(new PackingListResource($query));
} catch (\Exception $exception){
throw new ErrorException($exception->getMessage(), $exception->getCode());
}
}
}