/**
  * Handle the command.
  */
 public function handle()
 {
     $grid = $this->builder->getGrid();
     $model = $this->builder->getModel();
     /*
      * If the model is already instantiated
      * then use it as is.
      */
     if (is_object($model)) {
         $grid->setModel($model);
         return;
     }
     /*
      * If no model is set, try guessing the
      * model based on best practices.
      */
     if (!$model) {
         $parts = explode('\\', str_replace('GridBuilder', 'Model', get_class($this->builder)));
         unset($parts[count($parts) - 2]);
         $model = implode('\\', $parts);
         $this->builder->setModel($model);
     }
     /*
      * If the model is not set then skip it.
      */
     if (!class_exists($model)) {
         return;
     }
     /*
      * Set the model on the grid!
      */
     $grid->setModel(app($model));
 }
 /**
  * Handle the command.
  *
  * @param ResponseFactory $response
  */
 public function handle(ResponseFactory $response)
 {
     $grid = $this->builder->getGrid();
     $options = $grid->getOptions();
     $data = $grid->getData();
     $grid->setResponse($response->view($options->get('wrapper_view', 'streams::blank'), $data));
 }
Esempio n. 3
0
 /**
  * Handle the command.
  */
 public function handle()
 {
     $grid = $this->builder->getGrid();
     $options = $grid->getOptions();
     $data = $grid->getData();
     $content = view($options->get('grid_view', 'streams::grid/grid'), $data)->render();
     $grid->setContent($content);
     $grid->addData('content', $content);
 }
 /**
  * Handle the command.
  *
  * @param Resolver  $resolver
  * @param Evaluator $evaluator
  */
 public function handle(Resolver $resolver, Evaluator $evaluator)
 {
     $arguments = ['builder' => $this->builder];
     $grid = $this->builder->getGrid();
     $options = $this->builder->getOptions();
     $options = $resolver->resolve($options, $arguments);
     $options = $evaluator->evaluate($options, $arguments);
     foreach ($options as $key => $value) {
         $grid->setOption($key, $value);
     }
 }
 /**
  * Handle the command.
  */
 public function handle()
 {
     $grid = $this->builder->getGrid();
     /*
      * Set the default options handler based
      * on the builder class. Defaulting to
      * no handler.
      */
     if (!$grid->getOption('options')) {
         $options = str_replace('GridBuilder', 'GridOptions', get_class($this->builder));
         if (class_exists($options)) {
             app()->call($options . '@handle', compact('builder', 'grid'));
         }
     }
     /*
      * Set the default data handler based
      * on the builder class. Defaulting to
      * no handler.
      */
     if (!$grid->getOption('data')) {
         $options = str_replace('GridBuilder', 'GridData', get_class($this->builder));
         if (class_exists($options)) {
             $grid->setOption('data', $options . '@handle');
         }
     }
     /*
      * Set a optional entries handler based
      * on the builder class. Defaulting to
      * no handler in which case we will use
      * the model and included repositories.
      */
     if (!$grid->getOption('entries')) {
         $entries = str_replace('GridBuilder', 'GridEntries', get_class($this->builder));
         if (class_exists($entries)) {
             $grid->setOption('entries', $entries . '@handle');
         }
     }
     /*
      * Set the default options handler based
      * on the builder class. Defaulting to
      * no handler.
      */
     if (!$grid->getOption('repository')) {
         $model = $grid->getModel();
         if (!$grid->getOption('repository') && $model instanceof EntryModel) {
             $grid->setOption('repository', EntryGridRepository::class);
         }
         if (!$grid->getOption('repository') && $model instanceof EloquentModel) {
             $grid->setOption('repository', EloquentGridRepository::class);
         }
     }
 }
 /**
  * Handle the command.
  */
 public function handle()
 {
     $grid = $this->builder->getGrid();
     $model = $this->builder->getModel();
     if (is_string($model) && !class_exists($model)) {
         return;
     }
     if (is_string($model)) {
         $model = app($model);
     }
     if ($model instanceof EntryInterface) {
         $grid->setStream($model->getStream());
     }
 }
 /**
  * Handle the command.
  */
 public function handle()
 {
     $grid = $this->builder->getGrid();
     $model = $grid->getModel();
     $repository = $grid->getOption('repository');
     /**
      * If there is no repository
      * then skip this step.
      */
     if (!$repository) {
         return;
     }
     /**
      * Set the repository on the form!
      */
     $grid->setRepository(app()->make($repository, compact('model', 'grid')));
 }
Esempio n. 8
0
 /**
  * Handle the command.
  *
  * @param Container            $container
  * @param ViewTemplate         $template
  * @param BreadcrumbCollection $breadcrumbs
  */
 public function handle(Container $container, ViewTemplate $template, BreadcrumbCollection $breadcrumbs)
 {
     $grid = $this->builder->getGrid();
     $grid->addData('grid', $grid);
     if ($handler = $grid->getOption('data')) {
         $container->call($handler, compact('grid'));
     }
     if ($layout = $grid->getOption('layout_view')) {
         $template->put('layout', $layout);
     }
     if ($title = $grid->getOption('title')) {
         $template->put('title', $title);
     }
     if ($breadcrumb = $grid->getOption('breadcrumb')) {
         $breadcrumbs->put($breadcrumb, '#');
     }
 }
 /**
  * Handle the command.
  */
 public function handle()
 {
     $grid = $this->builder->getGrid();
     $model = $this->builder->getModel();
     /**
      * If the builder has an entries handler
      * then call it through the container and
      * let it load the entries itself.
      */
     if ($handler = $grid->getOption('entries')) {
         app()->call($handler, ['builder' => $this->builder]);
         return;
     }
     $entries = $grid->getEntries();
     /**
      * If the entries have already been set on the
      * grid then return. Nothing to do here.
      *
      * If the model is not set then they need
      * to load the grid entries themselves.
      */
     if (!$entries->isEmpty() || !$model) {
         return;
     }
     /**
      * Resolve the model out of the container.
      */
     $repository = $grid->getRepository();
     /**
      * If the repository is an instance of
      * GridRepositoryInterface use it.
      */
     if ($repository instanceof GridRepositoryInterface) {
         $grid->setEntries($repository->get($this->builder));
     }
 }
Esempio n. 10
0
 /**
  * Build the buttons.
  *
  * @param  GridBuilder      $builder
  * @param                   $entry
  * @return ButtonCollection
  */
 public function build(GridBuilder $builder, $entry)
 {
     $grid = $builder->getGrid();
     $buttons = new ButtonCollection();
     $this->input->read($builder, $entry);
     foreach ($builder->getButtons() as $button) {
         if (!array_get($button, 'enabled', true)) {
             continue;
         }
         $button = $this->evaluator->evaluate($button, compact('entry', 'grid'));
         $button = $this->parser->parser($button, $entry);
         $button = $this->factory->make($button);
         $buttons->push($button);
     }
     return $buttons;
 }