From ab526b7d8fc565314f20c840c7398096b9ec9b94 Mon Sep 17 00:00:00 2001 From: Justin Seliga Date: Mon, 5 Mar 2018 20:48:04 -0500 Subject: [PATCH] Add dispatchNow to Dispatchable Trait. --- src/Illuminate/Foundation/Bus/Dispatchable.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/Illuminate/Foundation/Bus/Dispatchable.php b/src/Illuminate/Foundation/Bus/Dispatchable.php index 62c465fe700b..bd509a96bb79 100644 --- a/src/Illuminate/Foundation/Bus/Dispatchable.php +++ b/src/Illuminate/Foundation/Bus/Dispatchable.php @@ -2,6 +2,8 @@ namespace Illuminate\Foundation\Bus; +use Illuminate\Contracts\Bus\Dispatcher; + trait Dispatchable { /** @@ -14,6 +16,16 @@ public static function dispatch() return new PendingDispatch(new static(...func_get_args())); } + /** + * Dispatch a command to its appropriate handler in the current process. + * + * @return mixed + */ + public static function dispatchNow() + { + return app(Dispatcher::class)->dispatchNow(new static(...func_get_args())); + } + /** * Set the jobs that should run if this job is successful. *