invoice_repo = $invoice_repo; } public function show(string $invitation_key) { $company = Company::where('company_key', $request->header('X-API-COMPANY_KEY'))->first(); if(!$company->enable_shop_api) return response()->json(['message' => 'Shop is disabled', 'errors' => []],403); $invitation = InvoiceInvitation::with(['invoice']) ->where('company_id', $company->id) ->where('key',$invitation_key) ->firstOrFail(); return $this->itemResponse($invitation->invoice); } public function store(StoreInvoiceRequest $request) { $company = Company::where('company_key', $request->header('X-API-COMPANY_KEY'))->first(); if(!$company->enable_shop_api) return response()->json(['message' => 'Shop is disabled', 'errors' => []],403); app('queue')->createPayloadUsing(function () use ($company) { return ['db' => $company->db]; }); $client = Client::find($request->input('client_id')); $invoice = $this->invoice_repo->save($request->all(), InvoiceFactory::create($company_id, $company->owner()->id)); event(new InvoiceWasCreated($invoice, $company, Ninja::eventVars())); $invoice = $invoice->service()->triggeredActions($request)->save(); return $this->itemResponse($invoice); } }