user()->company(); $company_user = CompanyUser::whereUserId($user->id)->whereCompanyId($company->id)->first(); if (! $company_user) { throw new ModelNotFoundException(ctrans('texts.company_user_not_found')); return; } if (auth()->user()->isAdmin()) { $company_user->fill($request->input('company_user')); } else { $company_user->settings = $request->input('company_user')['settings']; $company_user->notifications = $request->input('company_user')['notifications']; } $company_user->save(); return $this->itemResponse($company_user->fresh()); } public function updatePreferences(UpdateCompanyUserPreferencesRequest $request, User $user) { /** @var \App\Models\User $logged_in_user */ $company = auth()->user()->company(); $company_user = CompanyUser::whereUserId($user->id)->whereCompanyId($company->id)->first(); if (! $company_user) { throw new ModelNotFoundException(ctrans('texts.company_user_not_found')); return; } $this->entity_type = User::class; $this->entity_transformer = UserTransformer::class; $company_user->react_settings = $request->react_settings; $company_user->save(); return $this->itemResponse($user->fresh()); } /** * Remove the specified resource from storage. * * @param int $id * @return void */ public function destroy($id) { // } }