Files
shipping-portal/app/Classes/Modules/ContainerPackingLists/ControllersLogic/ListContainerPackingListsLogic.php
T
2021-07-24 11:39:40 +08:00

67 lines
2.1 KiB
PHP

<?php
namespace App\Classes\Modules\ContainerPackingLists\ControllersLogic;
use App\Classes\General\Abstracts\AbstractControllerLogic;
use App\Classes\Modules\ContainerPackingLists\Services\ListsContainerPackingLists;
use App\Classes\Modules\ContainerPackingLists\Standards\Rules\CanListContainerPackingLists;
use App\Http\Resources\ContainerPackingListResource;
use ErrorException;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
class ListContainerPackingListsLogic extends AbstractControllerLogic
{
/**
* @return array
*/
protected function notification():array {
return [
'title' => 'Retrieved ContainerPackingLists',
'message' => 'You have successfully retrieved a list of ContainerPackingLists'
];
}
/** @var CanListContainerPackingLists */
private $canListContainerPackingLists;
/** @var ListsContainerPackingLists */
private $listsContainerPackingLists;
/**
* ListContainerPackingListsLogic constructor.
* @param CanListContainerPackingLists $canListContainerPackingLists
* @param ListsContainerPackingLists $listsContainerPackingLists
*/
public function __construct(CanListContainerPackingLists $canListContainerPackingLists, ListsContainerPackingLists $listsContainerPackingLists)
{
$this->canListContainerPackingLists = $canListContainerPackingLists;
$this->listsContainerPackingLists = $listsContainerPackingLists;
}
/**
* @param Request $request
* @return JsonResponse
* @throws ErrorException
*/
public function logic(Request $request) : JsonResponse
{
try {
$this->canListContainerPackingLists->passes();
$query = $this->listsContainerPackingLists->execute($this->listsContainerPackingLists->deserializeFilters($request->input('filters')));
return $this->collectionResponse(ContainerPackingListResource::collection($query));
} catch (\Exception $exception){
throw new ErrorException($exception->getMessage(), $exception->getCode());
}
}
}