Level 1
from https://tenancyforlaravel.com/docs/v3/console-commands/
Artisan::call('tenants:run', [
'commandname' => 'scout:import',
'--tenants' => [$tenantId],
'--argument' => ["model={$className}"],
]);
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I have read https://laravel.com/docs/8.x/artisan#programmatically-executing-commands already but my commands are quite complex.
this is the command if I type from terminal
php artisan tenants:run scout:import --tenants="e99f2662-5d20-4157-b45e-91fb810f1d88" --argument="model=App\Models\Tenant\Application"
I wanted 'e99f2662-5d20-4157-b45e-91fb810f1d88' and 'App\Models\Tenant\Application' to be parametized as this is different from staging and production db.
This is what I have done so far inside a job
public function __construct(string $tenantId, string $className)
{
Artisan::call('tenants:run scout:import', ['tenants=' => $tenantId , 'argument' => "model=" . $className]);
}
this throws an error The command "tenants:run scout:import" does not exist. Thanks in advance.
Please or to participate in this conversation.