user(); $company = $auth_user->company(); $company_user = CompanyUser::query()->where('user_id', $user->id)->where('company_id', $company->id)->first(); if (! $company_user) { throw new ModelNotFoundException(ctrans('texts.company_user_not_found')); } 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']; if(isset($request->input('company_user')['react_settings'])) { $company_user->react_settings = $request->input('company_user')['react_settings']; } } $company_user->save(); return $this->itemResponse($company_user->fresh()); } public function updatePreferences(UpdateCompanyUserPreferencesRequest $request, User $user) { /** @var \App\Models\User $auth_user */ $auth_user = auth()->user(); $company = $auth_user->company(); $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')); } $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) { // } }