Skip to content

Commit

Permalink
Merge pull request #943 from bakaphp/KA-102
Browse files Browse the repository at this point in the history
refactor: override app
  • Loading branch information
FredPeal committed Feb 15, 2024
2 parents f0ac220 + 4d0faa7 commit 5dd6371
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
12 changes: 10 additions & 2 deletions src/Kanvas/Companies/Jobs/DeleteCompanyJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,31 @@
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
{
use Dispatchable;
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);
}
}

0 comments on commit 5dd6371

Please sign in to comment.