mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/shipping-portal.git
synced 2026-08-19 04:24:12 +00:00
64 lines
1.7 KiB
PHP
64 lines
1.7 KiB
PHP
<?php
|
|
|
|
|
|
namespace App\Classes\Modules\Delivery\ControllersLogic;
|
|
|
|
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
|
use App\Classes\Modules\Orders\Services\ListsOrders;
|
|
use App\Classes\Modules\Orders\Standards\Rules\CanListOrders;
|
|
use App\Classes\ValueObjects\Constants\OrderType;
|
|
use App\Http\Resources\DeliveryOrderResource;
|
|
use App\Http\Resources\OrderResource;
|
|
use ErrorException;
|
|
use Illuminate\Http\JsonResponse;
|
|
use Illuminate\Http\Request;
|
|
|
|
class ListOrdersLogic extends AbstractControllerLogic
|
|
{
|
|
/**
|
|
* @return array
|
|
*/
|
|
protected function notification():array {
|
|
return [
|
|
'title' => 'Retrieved Orders',
|
|
'message' => 'You have successfully retrieved a list of Orders'
|
|
];
|
|
}
|
|
|
|
/** @var CanListOrders */
|
|
private $canListOrders;
|
|
|
|
/** @var ListsOrders */
|
|
private $listsOrders;
|
|
|
|
/**
|
|
* ListOrdersLogic constructor.
|
|
* @param CanListOrders $canListOrders
|
|
* @param ListsOrders $listsOrders
|
|
*/
|
|
public function __construct(CanListOrders $canListOrders, ListsOrders $listsOrders)
|
|
{
|
|
$this->canListOrders = $canListOrders;
|
|
$this->listsOrders = $listsOrders;
|
|
}
|
|
|
|
public function logic(Request $request) : JsonResponse
|
|
{
|
|
$this->canListOrders->passes();
|
|
|
|
$query = $this->listsOrders->execute(array_merge($this->listsOrders->deserializeFilters($request->input('filters')), ['with_parcels' => true, 'type_in' => [OrderType::LAST_MILE_DELIVERY]]));
|
|
|
|
|
|
//no relationship needed
|
|
/* return fractal()
|
|
->collection($query, new DeliveryOrderTransformer)
|
|
->respond(200, [], JSON_PRETTY_PRINT);*/
|
|
|
|
return $this->collectionResponse(DeliveryOrderResource::collection($query));
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|