How to check If the current app process is running within a queue environment in Laravel

依然范特西╮ 提交于 2021-01-28 09:09:47

问题


I applied a global scope to my models via a trait, but I don't want the global scope applied when the model is called/processed from my Redis queue.

How do I detect if the current instance is a queue process? just like we have this

if (App::environment('local')) {
    // The environment is local
}

to detect if the app is running in local or production.


回答1:


Simply call:

app()->runningInConsole();

to check if execution is happening via cli.



来源:https://stackoverflow.com/questions/61243351/how-to-check-if-the-current-app-process-is-running-within-a-queue-environment-in

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!