/** * Handle the view query. * * @param TableBuilder $builder * @param Builder $query * @param ViewInterface $view * @return mixed * @throws \Exception */ public function handle(TableBuilder $builder, Builder $query, ViewInterface $view) { $view->fire('querying', compact('builder', 'query')); if (!($handler = $view->getQuery())) { return; } // Self handling implies @handle if (is_string($handler) && !str_contains($handler, '@')) { $handler .= '@handle'; } /* * If the handler is a callable string or Closure * then call it using the IoC container. */ if (is_string($handler) || $handler instanceof \Closure) { $this->container->call($handler, compact('builder', 'query')); } /* * If the handle is an instance of ViewQueryInterface * simply call the handle method on it. */ if ($handler instanceof ViewQueryInterface) { $handler->handle($builder, $query); } }