client_repo = $client_repo; } public function show(Request $request, string $contact_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); $contact = ClientContact::with('client') ->where('company_id', $company->id) ->where('contact_key', $contact_key) ->firstOrFail(); return $this->itemResponse($contact->client); } public function store(StoreShopClientRequest $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 = $this->client_repo->save($request->all(), ClientFactory::create($company->id, $company->owner()->id)); $client->load('contacts', 'primary_contact'); $this->uploadLogo($request->file('company_logo'), $company, $client); event(new ClientWasCreated($client, $company, Ninja::eventVars())); return $this->itemResponse($client); } }