Skip to content

Commit

Permalink
refactor: override app
Browse files Browse the repository at this point in the history
  • Loading branch information
FredPeal committed Feb 15, 2024
1 parent f0ac220 commit 04d756a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 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
14 changes: 11 additions & 3 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 04d756a

Please sign in to comment.