'Created Order', 'message' => 'You have successfully created a new Order' ]; } /** @var FetchesCompany */ private $fetchesCompany; /** @var fetchesAddress */ private $fetchesAddress; /** @var CreateOrderProcessor */ private $createOrderProcessor; /** @var FetchesCompanyModule */ private $fetchesCompanyModule; /** @var GeneratesOrderNumber */ private $generatesOrderNumber; /** * CreateOrderLogic constructor. * @param FetchesCompany $fetchesCompany * @param FetchesAddress $fetchesAddress * @param CreateOrderProcessor $createOrderProcessor * @param FetchesCompanyModule $fetchesCompanyModule * @param GeneratesOrderNumber $generatesOrderNumber */ public function __construct(FetchesCompany $fetchesCompany, FetchesAddress $fetchesAddress, CreateOrderProcessor $createOrderProcessor, FetchesCompanyModule $fetchesCompanyModule, GeneratesOrderNumber $generatesOrderNumber) { $this->fetchesCompany = $fetchesCompany; $this->fetchesAddress = $fetchesAddress; $this->createOrderProcessor = $createOrderProcessor; $this->fetchesCompanyModule = $fetchesCompanyModule; $this->generatesOrderNumber = $generatesOrderNumber; } public function logic(Request $request) : JsonResponse { $company = $this->fetchesCompany->execute(['id' => $request->input('company_id')]); $address = $this->fetchesAddress->execute(['id' => $request->input('address_id')]); $originWarehouse = $this->fetchesCompanyModule->execute(['id' => $request->input('warehouse_id')]); $order = $this->createOrderProcessor->execute($company, $originWarehouse, $address, $this->generatesOrderNumber->execute()); return $this->resourceResponse(new OrderResource($order)); } }