问题
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