public static function simpleMapping($command, $commandNamespace, $handlerNamespace) { $command = str_replace($commandNamespace, '', get_class($command)); return $handlerNamespace . '\\' . trim($command, '\\') . 'Handler@handle'; }
/** * Bootstrap any application services. * * @param \Illuminate\Bus\Dispatcher $dispatcher * @return void */ public function boot(Dispatcher $dispatcher) { $dispatcher->pipeThrough([CommandValidationPipe::class]); $dispatcher->mapUsing(function ($command) { return Dispatcher::simpleMapping($command, 'App\\Commands', 'App\\Handlers\\Commands'); }); }