mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/portal.git
synced 2026-08-21 13:34:08 +00:00
WIP - Order steps & remaining APIs
This commit is contained in:
@@ -6,7 +6,6 @@ namespace App\Classes\Modules\PackingLists\ControllersLogic;
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\PackingLists\Services\UpdatesPackingList;
|
||||
use App\Classes\Modules\PackingLists\Services\FetchesPackingList;
|
||||
use App\Classes\Modules\PackingLists\Services\FetchesDistrict;
|
||||
use App\Classes\Modules\PackingLists\Standards\Rules\CanUpdatePackingList;
|
||||
use App\Classes\Modules\PackingLists\DataTransferObjects\PackingListObject;
|
||||
use App\Http\Resources\PackingListResource;
|
||||
@@ -36,25 +35,19 @@ class UpdatePackingListLogic extends AbstractControllerLogic
|
||||
/** @var FetchesPackingList */
|
||||
private $fetchesPackingList;
|
||||
|
||||
/** @var FetchesDistrict */
|
||||
private $fetchesDistrict;
|
||||
|
||||
/**
|
||||
* UpdatePackingListLogic constructor.
|
||||
* @param CanUpdatePackingList $canUpdatePackingList
|
||||
* @param UpdatesPackingList $updatesPackingList
|
||||
* @param FetchesPackingList $fetchesPackingList
|
||||
* @param FetchesDistrict $fetchesDistrict
|
||||
*/
|
||||
public function __construct(CanUpdatePackingList $canUpdatePackingList, UpdatesPackingList $updatesPackingList, FetchesPackingList $fetchesPackingList, FetchesDistrict $fetchesDistrict)
|
||||
public function __construct(CanUpdatePackingList $canUpdatePackingList, UpdatesPackingList $updatesPackingList, FetchesPackingList $fetchesPackingList)
|
||||
{
|
||||
$this->canUpdatePackingList = $canUpdatePackingList;
|
||||
$this->updatesPackingList = $updatesPackingList;
|
||||
$this->fetchesPackingList = $fetchesPackingList;
|
||||
$this->fetchesDistrict = $fetchesDistrict;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
@@ -62,25 +55,15 @@ class UpdatePackingListLogic extends AbstractControllerLogic
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
try {
|
||||
$packingList = $this->fetchesPackingList->execute(['id' => $request->route('id')]);
|
||||
|
||||
$district = $this->fetchesDistrict->execute(['id' => $request->input('district_id')]);
|
||||
$object = new PackingListObject($request->input('street_one'), $request->input('street_two'), $district->country_id, $district->state_id, $district->id, $request->input('post_code'));
|
||||
//$object = new PackingListObject($request->input('company_id'), $request->input('street_one'), $request->input('street_two'), $request->input('city'), $request->input('state'), $request->input('post_code'), $request->input('country'), $request->input('default'), $request->input('billing'));
|
||||
$object = new PackingListObject($packingList->reference, $request->input('status'));
|
||||
|
||||
$this->canUpdatePackingList->passes($object);
|
||||
$this->canUpdatePackingList->passes($object);
|
||||
|
||||
$query = $this->fetchesPackingList->execute(['id' => $request->route('id')]);
|
||||
|
||||
$query = $this->updatesPackingList->execute($query, $object);
|
||||
|
||||
return $this->resourceResponse(new PackingListResource($query));
|
||||
|
||||
|
||||
} catch (\Exception $exception){
|
||||
throw new ErrorException($exception->getMessage(), $exception->getCode());
|
||||
}
|
||||
$query = $this->updatesPackingList->execute($packingList, $object);
|
||||
|
||||
return $this->resourceResponse(new PackingListResource($query));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user