'Created Transport', 'message' => 'You have successfully created a new Transport' ]; } /** @var CanCreateTransport */ private $canCreateTransport; /** @var FetchesContainerPackingList */ private $fetchesContainerPackingList; /** @var CreatesTransport */ private $createsTransport; /** * CreateTransportLogic constructor. * @param CanCreateTransport $canCreateTransport * @param FetchesContainerPackingList $fetchesContainerPackingList * @param CreatesTransport $createsTransport */ public function __construct(CanCreateTransport $canCreateTransport, FetchesContainerPackingList $fetchesContainerPackingList, CreatesTransport $createsTransport) { $this->canCreateTransport = $canCreateTransport; $this->fetchesContainerPackingList = $fetchesContainerPackingList; $this->createsTransport = $createsTransport; } /** * @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 { $object = new TransportObject($request->input('type'), $request->input('courier'), $request->input('tracking_number'), null, null, ApprovalStatus::PENDING_SUBMISSION); $this->canCreateTransport->passes($object); $query = $this->createsTransport->execute($this->fetchesContainerPackingList->execute(['id' => $request->input('container_id')]), $object); return $this->resourceResponse(new TransportResource($query)); } }