From 04d756aa2185aed1970df126c98fdb8de51472df Mon Sep 17 00:00:00 2001 From: FredPeal Date: Thu, 15 Feb 2024 13:59:24 -0400 Subject: [PATCH 1/2] refactor: override app --- .../Companies/CompanyManagementMutation.php | 2 +- src/Kanvas/Companies/Jobs/DeleteCompanyJob.php | 14 +++++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/app/GraphQL/Ecosystem/Mutations/Companies/CompanyManagementMutation.php b/app/GraphQL/Ecosystem/Mutations/Companies/CompanyManagementMutation.php index 783abd221..61600a602 100644 --- a/app/GraphQL/Ecosystem/Mutations/Companies/CompanyManagementMutation.php +++ b/app/GraphQL/Ecosystem/Mutations/Companies/CompanyManagementMutation.php @@ -66,7 +66,7 @@ public function deleteCompany(mixed $root, array $request): bool /** * @todo only super admin can do this */ - DeleteCompanyJob::dispatch((int) $request['id'], Auth::user()); + DeleteCompanyJob::dispatch((int) $request['id'], Auth::user(), app(Apps::class)); return true; } diff --git a/src/Kanvas/Companies/Jobs/DeleteCompanyJob.php b/src/Kanvas/Companies/Jobs/DeleteCompanyJob.php index 0e7f46b8d..52df2bc3f 100644 --- a/src/Kanvas/Companies/Jobs/DeleteCompanyJob.php +++ b/src/Kanvas/Companies/Jobs/DeleteCompanyJob.php @@ -11,6 +11,9 @@ use Illuminate\Queue\SerializesModels; use Kanvas\Companies\Actions\DeleteCompaniesAction; use Kanvas\Users\Models\Users; +use Kanvas\Apps\Models\Apps; +use Illuminate\Support\Facades\Auth; +use Baka\Traits\KanvasJobsTrait; class DeleteCompanyJob implements ShouldQueue { @@ -18,16 +21,21 @@ class DeleteCompanyJob implements ShouldQueue use InteractsWithQueue; use Queueable; use SerializesModels; + use KanvasJobsTrait; public function __construct( public int $companiesId, - public Users $user - ) { + public Users $user, + public Apps $app + ) { } public function handle(): void { - $companyDelete = new DeleteCompaniesAction($this->user); + Auth::loginUsingId($this->user->getId()); + $this->overwriteAppService($this->app); + + $companyDelete = new DeleteCompaniesAction($this->user, $this->app); $companyDelete->execute($this->companiesId); } } From ee02ea550be31eae14a08834f58ab599f1f37cbd Mon Sep 17 00:00:00 2001 From: StyleCI Bot Date: Thu, 15 Feb 2024 18:13:05 +0000 Subject: [PATCH 2/2] Apply fixes from StyleCI --- src/Kanvas/Companies/Jobs/DeleteCompanyJob.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Kanvas/Companies/Jobs/DeleteCompanyJob.php b/src/Kanvas/Companies/Jobs/DeleteCompanyJob.php index 52df2bc3f..8500003ee 100644 --- a/src/Kanvas/Companies/Jobs/DeleteCompanyJob.php +++ b/src/Kanvas/Companies/Jobs/DeleteCompanyJob.php @@ -27,14 +27,14 @@ public function __construct( public int $companiesId, public Users $user, public Apps $app - ) { + ) { } public function handle(): void { Auth::loginUsingId($this->user->getId()); $this->overwriteAppService($this->app); - + $companyDelete = new DeleteCompaniesAction($this->user, $this->app); $companyDelete->execute($this->companiesId); }