您可以检查控制台是否正在使用App::runningInConsole()
...这可能就足够了,具体取决于您运行迁移的方式。
更新:
好的,经过更多挖掘后,您似乎可以使用以下示例来获取所需的信息:
if(app()->runningInConsole()) {
// we are running in the console
$argv = \Request::server('argv', null);
// :$ php artisan migrate:refresh -v
//
// gives:
//
// $argv = array (
// 0 => 'artisan',
// 1 => 'migrate:refresh',
// 2 => '-v',
// )
if($argv[0] == 'artisan' && \Illuminate\Support\Str::contains($argv[1],'migrate')) {
// we are running the artisan migrate command
}
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
1913 次 |
最近记录: |