InitTenantData.php 847 B

12345678910111213141516171819202122232425262728293031323334
  1. <?php
  2. namespace App\Jobs;
  3. use Illuminate\Bus\Queueable;
  4. use Illuminate\Contracts\Queue\ShouldQueue;
  5. use Illuminate\Foundation\Bus\Dispatchable;
  6. use Illuminate\Queue\InteractsWithQueue;
  7. use Illuminate\Queue\SerializesModels;
  8. use Illuminate\Support\Facades\Artisan;
  9. use Stancl\Tenancy\Contracts\TenantWithDatabase;
  10. class InitTenantData implements ShouldQueue
  11. {
  12. use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
  13. protected TenantWithDatabase $tenant;
  14. public function __construct(TenantWithDatabase $tenant)
  15. {
  16. $this->tenant = $tenant;
  17. }
  18. /**
  19. * Execute the job.
  20. */
  21. public function handle(): void
  22. {
  23. Artisan::call('tenants:run', [
  24. 'commandname' => 'lpc:initialize-route-permission',
  25. '--tenants' => [$this->tenant->getTenantKey()],
  26. ]);
  27. }
  28. }