client_repo = $client_repo; } public function show(string $contact_key) { $company_token = CompanyToken::with(['company'])->whereRaw("BINARY `token`= ?", [$request->header('X-API-TOKEN')])->first(); $contact = ClientContact::with('client') ->where('company_id', $company_token->company->id) ->where('contact_key', $contact_key) ->firstOrFail(); return $this->itemResponse($contact->client); } public function store(StoreClientRequest $request) { $company_token = CompanyToken::with(['company'])->whereRaw("BINARY `token`= ?", [$request->header('X-API-TOKEN')])->first(); $client = $this->client_repo->save($request->all(), ClientFactory::create($company_token->company_id, $company_token->user_id)); $client->load('contacts', 'primary_contact'); $this->uploadLogo($request->file('company_logo'), $client->company, $client); event(new ClientWasCreated($client, $client->company, Ninja::eventVars())); return $this->itemResponse($client); } }