From 72fd21b69df104a4cc24b10caba49da5cbbf1e0e Mon Sep 17 00:00:00 2001 From: David Bomba Date: Wed, 5 Jul 2023 08:01:09 +1000 Subject: [PATCH] Send user/companyuser on update preferences --- app/Http/Controllers/CompanyUserController.php | 8 +++++++- app/Http/Controllers/UserController.php | 1 + lang/en/texts.php | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/CompanyUserController.php b/app/Http/Controllers/CompanyUserController.php index e14d1a9b09..1e3f686fe2 100644 --- a/app/Http/Controllers/CompanyUserController.php +++ b/app/Http/Controllers/CompanyUserController.php @@ -14,6 +14,7 @@ namespace App\Http\Controllers; use App\Models\User; use App\Models\CompanyUser; use Illuminate\Http\Response; +use App\Transformers\UserTransformer; use App\Transformers\CompanyUserTransformer; use Illuminate\Database\Eloquent\ModelNotFoundException; use App\Http\Requests\CompanyUser\UpdateCompanyUserRequest; @@ -134,6 +135,7 @@ class CompanyUserController extends BaseController 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(); @@ -143,10 +145,14 @@ class CompanyUserController extends BaseController return; } + $this->entity_type = User::class; + + $this->entity_transformer = UserTransformer::class; + $company_user->react_settings = $request->react_settings; $company_user->save(); - return $this->itemResponse($company_user->fresh()); + return $this->itemResponse($user->fresh()); } diff --git a/app/Http/Controllers/UserController.php b/app/Http/Controllers/UserController.php index bcabe5c16c..0e8d01b952 100644 --- a/app/Http/Controllers/UserController.php +++ b/app/Http/Controllers/UserController.php @@ -175,6 +175,7 @@ class UserController extends BaseController $user->oauth_user_refresh_token = null; $user->oauth_user_token = null; $user->save(); + UserEmailChanged::dispatch($new_user, json_decode($old_user), $logged_in_user->company()); } diff --git a/lang/en/texts.php b/lang/en/texts.php index 8d7f8c01f0..d4718a91ca 100644 --- a/lang/en/texts.php +++ b/lang/en/texts.php @@ -2260,7 +2260,7 @@ $LANG = array( 'restore_recurring_expense' => 'Restore Recurring Expense', 'restored_recurring_expense' => 'Successfully restored recurring expense', 'delete_recurring_expense' => 'Delete Recurring Expense', - 'deleted_recurring_expense' => 'Successfully deleted project', + 'deleted_recurring_expense' => 'Successfully deleted recurring expense', 'view_recurring_expense' => 'View Recurring Expense', 'taxes_and_fees' => 'Taxes and fees', 'import_failed' => 'Import Failed',