Пример #1
0
 /**
  * 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);
     }
 }
Пример #2
0
 /**
  * Handle the view's table modification.
  *
  * @param TableBuilder  $builder
  * @param ViewInterface $view
  */
 public function handle(TableBuilder $builder, ViewInterface $view)
 {
     if (!($handler = $view->getHandler())) {
         return;
     }
     /*
      * 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'));
     }
     /*
      * If the handle is an instance of ViewHandlerInterface
      * simply call the handle method on it.
      */
     if ($handler instanceof ViewHandlerInterface) {
         $handler->handle($builder);
     }
 }