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