mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/portal.git
synced 2026-09-02 03:14:12 +00:00
WIP - Order steps & remaining APIs
This commit is contained in:
+67
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Modules\ContainerPackingLists\ControllersLogic;
|
||||
|
||||
|
||||
use App\Classes\General\Abstracts\AbstractControllerLogic;
|
||||
use App\Classes\Modules\ContainerPackingLists\Services\CreatesContainerPackingList;
|
||||
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 ErrorException;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class CreateContainerPackingListLogic extends AbstractControllerLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function notification():array {
|
||||
return [
|
||||
'title' => 'Created PackingList',
|
||||
'message' => 'You have successfully created a new PackingList'
|
||||
];
|
||||
}
|
||||
|
||||
/** @var CanCreateContainerPackingList */
|
||||
private $canCreateContainerPackingList;
|
||||
|
||||
/** @var FetchesPackingList */
|
||||
private $fetchesPackingList;
|
||||
|
||||
/** @var CreatesPackingList */
|
||||
private $createsContainerPackingList;
|
||||
|
||||
public function __construct(CanCreateContainerPackingList $canCreateContainerPackingList, FetchesPackingList $fetchesPackingList, CreatesContainerPackingList $createsContainerPackingList)
|
||||
{
|
||||
$this->canCreateContainerPackingList = $canCreateContainerPackingList;
|
||||
$this->fetchesPackingList = $fetchesPackingList;
|
||||
$this->createsContainerPackingList = $createsContainerPackingList;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
* @return JsonResponse
|
||||
* @throws \App\Classes\Exceptions\AccessForbiddenException
|
||||
* @throws \App\Classes\Exceptions\MalformedRequestException
|
||||
* @throws \App\Classes\Exceptions\RequestValidationException
|
||||
*/
|
||||
public function logic(Request $request) : JsonResponse
|
||||
{
|
||||
|
||||
$packingList = $this->fetchesPackingList->execute(['id' => $request->input('packing_list_id')]);
|
||||
|
||||
$object = new ContainerPackingListObject( $packingList->id , $request->input('container_reference'), $request->input('container_type'), $request->input('seal_reference'));
|
||||
|
||||
$this->canCreateContainerPackingList->passes($object);
|
||||
|
||||
$query = $this->createsContainerPackingList->execute($object);
|
||||
|
||||
return $this->resourceResponse(new PackingListResource($packingList));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user