Last active
June 24, 2022 13:03
-
-
Save ricardov03/dfc5cb865f5fa864e86481a9be517d70 to your computer and use it in GitHub Desktop.
This sample is how to execute Artisan Commands with Spatie Laravel-multitenancy with Laravel APP_ENV environment set to 'production'.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| // This sample present the same command. But the one executed in 'local' doesn't work if Laravel APP_ENV is set to production. | |
| if(app()->environment('local')) | |
| Artisan::call('tenants:artisan "migrate --database=tenant --seed" -q --tenant=' . $customer->getkey()); | |
| // Is necessary to understand the --force flag is set on the artisanCommand variable and NOT in the global scoped executed command. | |
| // This is because the artisanCommand on the tenants:artisan defines the final artisan command to execute on each tenant. | |
| // For more information related to Artisan Commands Production environments check this [article](https://divinglaravel.com/the-problem-behind-undefined-constant-stdin-when-running-laravel-artisan-command-programmatically) from Mohammed Said. | |
| if(app()->environment('production')) | |
| Artisan::call('tenants:artisan', [ | |
| 'artisanCommand' => 'migrate --seed --force', | |
| '--tenant' => $customer->getkey() | |
| ]); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment