mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/portal.git
synced 2026-09-02 11:24:31 +00:00
WIP - Order steps & remaining APIs
This commit is contained in:
+2
-2
@@ -8,7 +8,7 @@ use App\Classes\Modules\ContainerPackingLists\Services\CreatesContainerPackingLi
|
||||
use App\Classes\Modules\ContainerPackingLists\Standards\Rules\CanCreateContainerPackingList;
|
||||
use App\Classes\Modules\ContainerPackingLists\DataTransferObjects\ContainerPackingListObject;
|
||||
use App\Classes\Modules\PackingLists\Services\FetchesPackingList;
|
||||
use App\Http\Resources\PackingListResource;
|
||||
use App\Http\Resources\ContainerPackingListResource;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -60,7 +60,7 @@ class CreateContainerPackingListLogic extends AbstractControllerLogic
|
||||
|
||||
$query = $this->createsContainerPackingList->execute($object);
|
||||
|
||||
return $this->resourceResponse(new PackingListResource($packingList));
|
||||
return $this->resourceResponse(new ContainerPackingListResource($query));
|
||||
|
||||
}
|
||||
|
||||
|
||||
-66
@@ -1,66 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\ContainerPackingLists\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\ContainerPackingLists\Services\FetchesContainerPackingList;
|
||||
use App\Classes\Modules\ContainerPackingLists\Standards\Rules\CanFetchContainerPackingList;
|
||||
use App\Http\Resources\ContainerPackingListResource;
|
||||
use ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class FetchContainerPackingListLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Retrieved ContainerPackingList',
|
||||
'message' => 'You have successfully retrieved a ContainerPackingList'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var CanFetchContainerPackingList */
|
||||
private $canFetchContainerPackingList;
|
||||
|
||||
/** @var FetchesContainerPackingList */
|
||||
private $fetchesContainerPackingList;
|
||||
|
||||
/**
|
||||
* FetchContainerPackingListControllersLogic constructor.
|
||||
* @param CanFetchContainerPackingList $canFetchContainerPackingList
|
||||
* @param FetchesContainerPackingList $fetchesContainerPackingList
|
||||
*/
|
||||
public function __construct(CanFetchContainerPackingList $canFetchContainerPackingList, FetchesContainerPackingList $fetchesContainerPackingList)
|
||||
{
|
||||
$this->canFetchContainerPackingList = $canFetchContainerPackingList;
|
||||
$this->fetchesContainerPackingList = $fetchesContainerPackingList;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws ErrorException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
try {
|
||||
|
||||
$this->canFetchContainerPackingList->passes();
|
||||
|
||||
$query = $this->fetchesContainerPackingList->execute(['id' => $request->route('id')]);
|
||||
|
||||
return $this->resourceResponse(new ContainerPackingListResource($query));
|
||||
|
||||
} catch (\Exception $exception){
|
||||
throw new ErrorException($exception->getMessage(), $exception->getCode());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+6
-20
@@ -6,7 +6,6 @@ namespace App\Classes\Modules\ContainerPackingLists\ControllersLogic;
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\ContainerPackingLists\Services\UpdatesContainerPackingList;
|
||||
use App\Classes\Modules\ContainerPackingLists\Services\FetchesContainerPackingList;
|
||||
use App\Classes\Modules\ContainerPackingLists\Services\FetchesDistrict;
|
||||
use App\Classes\Modules\ContainerPackingLists\Standards\Rules\CanUpdateContainerPackingList;
|
||||
use App\Classes\Modules\ContainerPackingLists\DataTransferObjects\ContainerPackingListObject;
|
||||
use App\Http\Resources\ContainerPackingListResource;
|
||||
@@ -36,22 +35,17 @@ class UpdateContainerPackingListLogic extends AbstractControllerLogic
|
||||
/** @var FetchesContainerPackingList */
|
||||
private $fetchesContainerPackingList;
|
||||
|
||||
/** @var FetchesDistrict */
|
||||
private $fetchesDistrict;
|
||||
|
||||
/**
|
||||
* UpdateContainerPackingListLogic constructor.
|
||||
* @param CanUpdateContainerPackingList $canUpdateContainerPackingList
|
||||
* @param UpdatesContainerPackingList $updatesContainerPackingList
|
||||
* @param FetchesContainerPackingList $fetchesContainerPackingList
|
||||
* @param FetchesDistrict $fetchesDistrict
|
||||
*/
|
||||
public function __construct(CanUpdateContainerPackingList $canUpdateContainerPackingList, UpdatesContainerPackingList $updatesContainerPackingList, FetchesContainerPackingList $fetchesContainerPackingList, FetchesDistrict $fetchesDistrict)
|
||||
public function __construct(CanUpdateContainerPackingList $canUpdateContainerPackingList, UpdatesContainerPackingList $updatesContainerPackingList, FetchesContainerPackingList $fetchesContainerPackingList)
|
||||
{
|
||||
$this->canUpdateContainerPackingList = $canUpdateContainerPackingList;
|
||||
$this->updatesContainerPackingList = $updatesContainerPackingList;
|
||||
$this->fetchesContainerPackingList = $fetchesContainerPackingList;
|
||||
$this->fetchesDistrict = $fetchesDistrict;
|
||||
}
|
||||
|
||||
|
||||
@@ -62,24 +56,16 @@ class UpdateContainerPackingListLogic extends AbstractControllerLogic
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
try {
|
||||
|
||||
$district = $this->fetchesDistrict->execute(['id' => $request->input('district_id')]);
|
||||
$object = new ContainerPackingListObject($request->input('street_one'), $request->input('street_two'), $district->country_id, $district->state_id, $district->id, $request->input('post_code'));
|
||||
//$object = new ContainerPackingListObject($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'));
|
||||
$container = $this->fetchesContainerPackingList->execute(['id' => $request->route('id')]);
|
||||
|
||||
$this->canUpdateContainerPackingList->passes($object);
|
||||
$object = new ContainerPackingListObject( $container->packing_list_id , $request->input('container_reference'), $request->input('container_type'), $request->input('seal_reference'));
|
||||
|
||||
$query = $this->fetchesContainerPackingList->execute(['id' => $request->route('id')]);
|
||||
$this->canUpdateContainerPackingList->passes($object);
|
||||
|
||||
$query = $this->updatesContainerPackingList->execute($query, $object);
|
||||
$query = $this->updatesContainerPackingList->execute($container, $object);
|
||||
|
||||
return $this->resourceResponse(new ContainerPackingListResource($query));
|
||||
|
||||
|
||||
} catch (\Exception $exception){
|
||||
throw new ErrorException($exception->getMessage(), $exception->getCode());
|
||||
}
|
||||
return $this->resourceResponse(new ContainerPackingListResource($query));
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user