From 28e3defc83cea50a38fc6f967109440b95c55aae Mon Sep 17 00:00:00 2001 From: David Bomba Date: Thu, 24 Jun 2021 18:42:45 +1000 Subject: [PATCH 1/2] Fixes for dissociated default_company --- app/Http/Controllers/Auth/LoginController.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/Http/Controllers/Auth/LoginController.php b/app/Http/Controllers/Auth/LoginController.php index b806f69675cd..5a191d928eae 100644 --- a/app/Http/Controllers/Auth/LoginController.php +++ b/app/Http/Controllers/Auth/LoginController.php @@ -201,6 +201,14 @@ class LoginController extends BaseController ->header('X-Api-Version', config('ninja.minimum_client_version')); } + /* If for some reason we lose state on the default company ie. a company is deleted - always make sure we can default to a company*/ + if(!$user->account->default_company){ + $account = $user->account; + $account->default_company_id = $user->companies->first()->id; + $account->save(); + $user = $user->fresh(); + } + $user->setCompany($user->account->default_company); $this->setLoginCache($user); From ff78f354e41fbfa4bf861d7f7f26c89700e1e1c2 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Thu, 24 Jun 2021 20:01:22 +1000 Subject: [PATCH 2/2] set exchange_rate_id to nullable --- ...95942_payments_table_currency_nullable.php | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 database/migrations/2021_06_24_095942_payments_table_currency_nullable.php diff --git a/database/migrations/2021_06_24_095942_payments_table_currency_nullable.php b/database/migrations/2021_06_24_095942_payments_table_currency_nullable.php new file mode 100644 index 000000000000..02381a29c181 --- /dev/null +++ b/database/migrations/2021_06_24_095942_payments_table_currency_nullable.php @@ -0,0 +1,32 @@ +unsignedInteger('exchange_currency_id')->nullable()->change(); + + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + // + } +}