'Created Company Wallet', 'message' => 'You have successfully created a company wallet' ]; } /** @var CreatesWallet */ private $createsWallet; /** @var GeneratesWalletCode */ private $generatesWalletCode; /** @var CanCreateCompanyWallet */ private $canCreateCompanyWallet; /** @var FetchesCompanyModule */ private $fetchesCompanyModule; /** * CreateWalletLogic constructor. * @param CreatesWallet $createsWallet * @param GeneratesWalletCode $generatesWalletCode * @param CanCreateCompanyWallet $canCreateCompanyWallet */ public function __construct(CreatesWallet $createsWallet, GeneratesWalletCode $generatesWalletCode, CanCreateCompanyWallet $canCreateCompanyWallet, FetchesCompanyModule $fetchesCompanyModule) { $this->fetchesCompanyModule = $fetchesCompanyModule; $this->createsWallet = $createsWallet; $this->generatesWalletCode = $generatesWalletCode; $this->canCreateCompanyWallet = $canCreateCompanyWallet; } /** * @param Request $request * @return JsonResponse * @throws ErrorException */ public function logic(Request $request) : JsonResponse { $object = new WalletObject($request->input('company_module_id'), $request->input('currency_id'), $this->generatesWalletCode->execute()); $this->canCreateCompanyWallet->passes($object); $company_module = $this->fetchesCompanyModule->execute(['id' => $request->input('company_id')]); $wallet = $this->createsWallet->execute($object, $company_module); return $this->resourceResponse(new WalletResource($wallet)); } }