1 | <?php |
||||||
2 | |||||||
3 | namespace App\Console\Commands; |
||||||
4 | |||||||
5 | use App\Models\Tenant; |
||||||
6 | use App\Services\TenantManager; |
||||||
7 | use Illuminate\Console\Command; |
||||||
8 | use Symfony\Component\Console\Exception\RuntimeException; |
||||||
9 | |||||||
10 | class TenantSeed extends Command |
||||||
11 | { |
||||||
12 | /** |
||||||
13 | * The name and signature of the console command. |
||||||
14 | * |
||||||
15 | * @var string |
||||||
16 | */ |
||||||
17 | protected $signature = 'tenant:seed {tenantId}'; |
||||||
18 | |||||||
19 | /** |
||||||
20 | * The console command description. |
||||||
21 | * |
||||||
22 | * @var string |
||||||
23 | */ |
||||||
24 | protected $description = 'Seed teenant with necessary data'; |
||||||
25 | |||||||
26 | protected $tenantManager; |
||||||
27 | |||||||
28 | /** |
||||||
29 | * Create a new command instance. |
||||||
30 | * |
||||||
31 | * @param TenantManager $tenantManager |
||||||
32 | */ |
||||||
33 | public function __construct(TenantManager $tenantManager) |
||||||
34 | { |
||||||
35 | parent::__construct(); |
||||||
36 | |||||||
37 | $this->tenantManager = $tenantManager; |
||||||
38 | } |
||||||
39 | |||||||
40 | /** |
||||||
41 | * Execute the console command. |
||||||
42 | * |
||||||
43 | * @return mixed |
||||||
44 | */ |
||||||
45 | public function handle() |
||||||
46 | { |
||||||
47 | $tenantId = $this->argument('tenantId'); |
||||||
48 | $tenant = Tenant::find($tenantId); |
||||||
49 | |||||||
50 | if (!$tenant) { |
||||||
51 | throw new RuntimeException('Tenant with ID = '.$tenantId.' does not exist.'); |
||||||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||||||
52 | } |
||||||
53 | |||||||
54 | $this->tenantManager->setTenant($tenant); |
||||||
55 | \DB::purge('tenant'); |
||||||
56 | |||||||
57 | $seeder = new \RolesAndPermissionsSeeder('tenant'); |
||||||
58 | $seeder->run(null); |
||||||
0 ignored issues
–
show
The call to
RolesAndPermissionsSeeder::run() has too many arguments starting with null .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue. If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above. ![]() |
|||||||
59 | |||||||
60 | $this->info('Data have been seeded for tenant with subdomain \''.$tenant->subdomain.'\'.'); |
||||||
61 | } |
||||||
62 | } |
||||||
63 |