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 SeedDemoData extends Command |
||||
11 | { |
||||
12 | /** |
||||
13 | * The name and signature of the console command. |
||||
14 | * |
||||
15 | * @var string |
||||
16 | */ |
||||
17 | protected $signature = 'tenant:seeddemodata {tenantId}'; |
||||
18 | |||||
19 | /** |
||||
20 | * The console command description. |
||||
21 | * |
||||
22 | * @var string |
||||
23 | */ |
||||
24 | protected $description = 'Seed teenant database with example recruitments and fake candidates'; |
||||
25 | |||||
26 | protected $tenantManager; |
||||
27 | |||||
28 | /** |
||||
29 | * Create a new command instance. |
||||
30 | * |
||||
31 | * @return void |
||||
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 \ExampleRecruitments(); |
||||
0 ignored issues
–
show
The call to
ExampleRecruitments::__construct() has too few arguments starting with connection .
(
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 less 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. ![]() |
|||||
58 | $seeder->setConnection('tenant'); |
||||
59 | $seeder->run(); |
||||
60 | |||||
61 | $seeder = new \ExampleCandidates(); |
||||
0 ignored issues
–
show
The call to
ExampleCandidates::__construct() has too few arguments starting with connection .
(
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 less 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. ![]() |
|||||
62 | $seeder->setConnection('tenant'); |
||||
63 | $seeder->run(); |
||||
64 | |||||
65 | $seeder = new \ExampleStages(); |
||||
0 ignored issues
–
show
The call to
ExampleStages::__construct() has too few arguments starting with connection .
(
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 less 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. ![]() |
|||||
66 | $seeder->setConnection('tenant'); |
||||
67 | $seeder->run(); |
||||
68 | |||||
69 | $seeder = new \ExamplePredefinedMessages(); |
||||
0 ignored issues
–
show
The call to
ExamplePredefinedMessages::__construct() has too few arguments starting with connection .
(
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 less 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. ![]() |
|||||
70 | $seeder->setConnection('tenant'); |
||||
71 | $seeder->run(); |
||||
72 | |||||
73 | $this->info('Demo data have been seeded for tenant with subdomain \''.$tenant->subdomain.'\'.'); |
||||
74 | } |
||||
75 | } |
||||
76 |