mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/izyim.git
synced 2026-08-19 20:44:03 +00:00
8a28eb1790
This reverts merge request !5
61 lines
2.2 KiB
PHP
61 lines
2.2 KiB
PHP
<?php
|
|
|
|
namespace App\Classes\Modules\ControllersLogic\Warehouses;
|
|
|
|
|
|
use App\Classes\Modules\Companies\Exceptions\CannotListCompanyOrderCategoryException;
|
|
use App\Classes\Modules\Warehouses\Services\FetchWarehouseOrderCategorySteps;
|
|
use App\Classes\Modules\Warehouses\Services\ListsWarehouseCompleteOrders;
|
|
use App\Classes\Modules\Warehouses\Services\ListsWarehouseOrdersCategory;
|
|
use App\Classes\Modules\ControllerLogic\Exceptions\InternalServerErrorException;
|
|
use App\Classes\ValueObjects\Constants\OrderSteps;
|
|
|
|
class ListWarehouseOrderLogic
|
|
{
|
|
|
|
/** @var FetchWarehouseOrderCategorySteps */
|
|
private $fetchOrderCategorySteps;
|
|
|
|
/** @var ListsWarehouseOrdersCategory */
|
|
private $listOrdersCategory;
|
|
|
|
/** @var ListsWarehouseCompleteOrders */
|
|
private $listCompleteOrders;
|
|
|
|
/**
|
|
* ListWarehouseOrderLogic constructor.
|
|
* @param FetchWarehouseOrderCategorySteps $fetchOrderCategorySteps
|
|
* @param ListsWarehouseOrdersCategory $listOrdersCategory
|
|
* @param ListsWarehouseCompleteOrders $listCompleteOrders
|
|
*/
|
|
public function __construct(FetchWarehouseOrderCategorySteps $fetchOrderCategorySteps, ListsWarehouseOrdersCategory $listOrdersCategory, ListsWarehouseCompleteOrders $listCompleteOrders)
|
|
{
|
|
$this->fetchOrderCategorySteps = $fetchOrderCategorySteps;
|
|
$this->listOrdersCategory = $listOrdersCategory;
|
|
$this->listCompleteOrders = $listCompleteOrders;
|
|
}
|
|
|
|
|
|
/**
|
|
* @param int $id
|
|
* @param string $category
|
|
* @return \Illuminate\Http\Resources\Json\AnonymousResourceCollection
|
|
* @throws InternalServerErrorException
|
|
*/
|
|
public function execute(int $id, string $category){
|
|
try {
|
|
switch ($category){
|
|
case OrderSteps::WAREHOUSE_COMPLETE_CATEGORY:
|
|
return $this->listCompleteOrders->execute($id, $this->fetchOrderCategorySteps->execute($category));
|
|
default:
|
|
return $this->listOrdersCategory->execute($id, $this->fetchOrderCategorySteps->execute($category));
|
|
|
|
}
|
|
|
|
} catch (CannotListCompanyOrderCategoryException $exception){
|
|
throw new InternalServerErrorException('Cannot list warehouse\'s orders in '.$category.' category because'.$exception);
|
|
}
|
|
|
|
}
|
|
|
|
} |