mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal.git
synced 2026-08-19 12:34:18 +00:00
73 lines
2.0 KiB
PHP
73 lines
2.0 KiB
PHP
<?php
|
|
|
|
namespace App\Classes\Modules\PackingLists\ControllersLogic;
|
|
|
|
|
|
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
|
use App\Classes\Modules\PackingLists\Services\ListsPackingLists;
|
|
use App\Classes\Modules\PackingLists\Standards\Rules\CanListPackingLists;
|
|
use App\Http\Resources\PackingListNullOrderResource;
|
|
use App\Http\Resources\PackingListResource;
|
|
use App\Transformers\PackageListTransformer;
|
|
use ErrorException;
|
|
use Illuminate\Http\JsonResponse;
|
|
use Illuminate\Http\Request;
|
|
use Spatie\Fractalistic\ArraySerializer;
|
|
|
|
class ListPackingListsLogic extends AbstractControllerLogic
|
|
{
|
|
|
|
/**
|
|
* @return array
|
|
*/
|
|
protected function notification(): array
|
|
{
|
|
return [
|
|
'title' => 'Retrieved PackingLists',
|
|
'message' => 'You have successfully retrieved a list of PackingLists'
|
|
];
|
|
}
|
|
|
|
/** @var CanListPackingLists */
|
|
private $canListPackingLists;
|
|
|
|
/** @var ListsPackingLists */
|
|
private $listsPackingLists;
|
|
|
|
/**
|
|
* ListPackingListsLogic constructor.
|
|
* @param CanListPackingLists $canListPackingLists
|
|
* @param ListsPackingLists $listsPackingLists
|
|
*/
|
|
public function __construct(CanListPackingLists $canListPackingLists, ListsPackingLists $listsPackingLists)
|
|
{
|
|
$this->canListPackingLists = $canListPackingLists;
|
|
$this->listsPackingLists = $listsPackingLists;
|
|
}
|
|
|
|
|
|
/**
|
|
* @param Request $request
|
|
* @return JsonResponse
|
|
* @throws ErrorException
|
|
*/
|
|
public function logic(Request $request): JsonResponse
|
|
{
|
|
$this->canListPackingLists->passes();
|
|
|
|
$query = $this->listsPackingLists->execute($this->listsPackingLists->deserializeFilters($request->input('filters')));
|
|
|
|
return fractal()
|
|
->parseIncludes(['transport', 'packages'])
|
|
->collection($query, new PackageListTransformer(), "data")
|
|
->serializeWith(new ArraySerializer())
|
|
->respond(200, [], JSON_PRETTY_PRINT);
|
|
|
|
|
|
//return $this->collectionResponse(PackingListResource::collection($query));
|
|
|
|
|
|
}
|
|
|
|
}
|