How to send yes when executing a custom command in laravel?

838 views Asked by At

I am making a multitenant application using spatie/multi-tenancy. And I need to migrate the database when the new tenant is created. However, as the application is in production, it prompts before migration. I am executing this command.

Artisan::call("tenants:artisan 'migrate --seed' --tenant={$tenant->id}");

This command works perfectly when in the local environment but not when setting up the application in production. I am not able to pass --force as it shows this option does not exist. I want to know how to go about this. I have tried

        echo "y" | Artisan::call("tenants:artisan 'migrate --seed' --tenant={$tenant->id}");

But this doesn't work. Any suggestions? Maybe adding some option in the command itself which will automatically send 'yes' when prompted.

0

There are 0 answers