/**
  * Handle the command.
  *
  * @param ResponseFactory $response
  */
 public function handle(ResponseFactory $response)
 {
     $table = $this->builder->getTable();
     $options = $table->getOptions();
     $data = $table->getData();
     $table->setResponse($response->view($options->get('wrapper_view', $this->builder->isAjax() ? 'streams::ajax' : 'streams::blank'), $data));
 }
 /**
  * Handle the command.
  *
  * @param Request   $request
  * @param Container $container
  */
 public function handle(Request $request, ViewHandler $handler)
 {
     $table = $this->builder->getTable();
     $options = $table->getOptions();
     $views = $table->getViews();
     if ($views->active()) {
         return;
     }
     if ($view = $views->findBySlug($request->get($options->get('prefix') . 'view'))) {
         $view->setActive(true);
     }
     if (!$view && ($view = $views->first())) {
         $view->setActive(true);
     }
     // Nothing to do.
     if (!$view) {
         return;
     }
     // Set columns from active view.
     if (($columns = $view->getColumns()) !== null) {
         $this->builder->setColumns($columns);
     }
     // Set buttons from active view.
     if (($buttons = $view->getButtons()) !== null) {
         $this->builder->setButtons($buttons);
     }
     // Set actions from active view.
     if (($actions = $view->getActions()) !== null) {
         $this->builder->setActions($actions);
     }
     $handler->handle($this->builder, $view);
 }
 /**
  * Handle the command.
  */
 public function handle()
 {
     $table = $this->builder->getTable();
     $model = $this->builder->getModel();
     /*
      * If the model is already instantiated
      * then use it as is.
      */
     if (is_object($model)) {
         $table->setModel($model);
         return;
     }
     /*
      * If no model is set, try guessing the
      * model based on best practices.
      */
     if ($model === null) {
         $parts = explode('\\', str_replace('TableBuilder', 'Model', get_class($this->builder)));
         unset($parts[count($parts) - 2]);
         $model = implode('\\', $parts);
         $this->builder->setModel($model);
     }
     /*
      * If the model does not exist or
      * is disabled then skip it.
      */
     if (!$model || !class_exists($model)) {
         return;
     }
     /*
      * Set the model on the table!
      */
     $table->setModel(app($model));
 }
示例#4
0
 /**
  * Handle the command.
  */
 public function handle()
 {
     $table = $this->builder->getTable();
     $options = $table->getOptions();
     $data = $table->getData();
     $content = view($options->get('table_view', $this->builder->isAjax() ? 'streams::table/ajax' : 'streams::table/table'), $data)->render();
     $table->setContent($content);
     $table->addData('content', $content);
 }
 /**
  * Handle the command.
  */
 public function handle()
 {
     $table = $this->builder->getTable();
     $model = $this->builder->getModel();
     if (is_string($model) && !class_exists($model)) {
         return;
     }
     if (is_string($model)) {
         $model = app($model);
     }
     if ($model instanceof EntryInterface) {
         $table->setStream($model->getStream());
     }
 }
示例#6
0
 /**
  * Handle the command.
  *
  * @param Container            $container
  * @param ViewTemplate         $template
  * @param BreadcrumbCollection $breadcrumbs
  */
 public function handle(Container $container, ViewTemplate $template, BreadcrumbCollection $breadcrumbs)
 {
     $table = $this->builder->getTable();
     $table->addData('table', $table);
     if ($handler = $table->getOption('data')) {
         $container->call($handler, compact('table'));
     }
     if ($layout = $table->getOption('layout_view')) {
         $template->put('layout', $layout);
     }
     if ($title = $table->getOption('title')) {
         $template->put('title', $title);
     }
     $this->dispatch(new LoadTablePagination($table));
     if ($breadcrumb = $table->getOption('breadcrumb')) {
         $breadcrumbs->put($breadcrumb, '#');
     }
 }
 /**
  * Build the actions.
  *
  * @param TableBuilder $builder
  */
 public function build(TableBuilder $builder)
 {
     $table = $builder->getTable();
     $this->input->read($builder);
     foreach ($builder->getActions() as $action) {
         if (array_get($action, 'enabled', true)) {
             $table->addAction($this->factory->make($action));
         }
     }
 }
 /**
  * Build the filters.
  *
  * @param TableBuilder $builder
  */
 public function build(TableBuilder $builder)
 {
     $table = $builder->getTable();
     $this->input->read($builder);
     foreach ($builder->getFilters() as $filter) {
         if (array_get($filter, 'enabled') === false) {
             continue;
         }
         $table->addFilter($this->factory->make($filter));
     }
 }
 /**
  * Build the headers.
  *
  * @param TableBuilder $builder
  */
 public function build(TableBuilder $builder)
 {
     $table = $builder->getTable();
     $this->input->read($builder);
     if ($builder->getTableOption('enable_headers') === false) {
         return;
     }
     foreach ($builder->getColumns() as $column) {
         $column['builder'] = $builder;
         $table->addHeader($this->factory->make($column));
     }
 }
 /**
  * Handle the command.
  *
  * @param ModuleCollection $modules
  */
 public function handle(ModuleCollection $modules)
 {
     $table = $this->builder->getTable();
     /**
      * Set the default sortable option.
      */
     if ($table->getOption('sortable') === null) {
         $stream = $table->getStream();
         if ($stream && $stream->isSortable()) {
             $table->setOption('sortable', true);
         }
     }
     /**
      * Sortable tables have no pages.
      */
     if ($table->getOption('sortable') === true) {
         $table->setOption('limit', $table->getOption('limit', 99999));
     }
     /**
      * Set the default breadcrumb.
      */
     if ($table->getOption('breadcrumb') === null && ($title = $table->getOption('title'))) {
         $table->setOption('breadcrumb', $title);
     }
     /**
      * If the table ordering is currently being overridden
      * then set the values from the request on the builder
      * last so it actually has an effect.
      */
     if ($orderBy = $this->builder->getRequestValue('order_by')) {
         $table->setOption('order_by', [$orderBy => $this->builder->getRequestValue('sort', 'asc')]);
     }
     /**
      * If the permission is not set then
      * try and automate it.
      */
     if ($table->getOption('permission') === null && ($module = $modules->active()) && ($stream = $this->builder->getTableStream())) {
         $table->setOption('permission', $module->getNamespace($stream->getSlug() . '.read'));
     }
 }
示例#11
0
 /**
  * Build the views.
  *
  * @param TableBuilder $builder
  */
 public function build(TableBuilder $builder)
 {
     $table = $builder->getTable();
     $this->input->read($builder);
     if ($builder->getTableOption('enable_views') === false) {
         return;
     }
     foreach ($builder->getViews() as $view) {
         if (array_get($view, 'enabled', true)) {
             $table->addView($this->factory->make($view));
         }
     }
 }
 /**
  * Build the columns.
  *
  * @param  TableBuilder     $builder
  * @param                   $entry
  * @return ColumnCollection
  */
 public function build(TableBuilder $builder, $entry)
 {
     $table = $builder->getTable();
     $columns = new ColumnCollection();
     $this->input->read($builder);
     foreach ($builder->getColumns() as $column) {
         array_set($column, 'entry', $entry);
         $column = $this->evaluator->evaluate($column, compact('entry', 'table'));
         $column['value'] = $this->value->make($table, $column, $entry);
         $columns->push($this->factory->make($column));
     }
     return $columns;
 }
 /**
  * Build the buttons.
  *
  * @param  TableBuilder $builder
  * @param                   $entry
  * @return ButtonCollection
  */
 public function build(TableBuilder $builder, $entry)
 {
     $table = $builder->getTable();
     $buttons = new ButtonCollection();
     $this->input->read($builder);
     foreach ($builder->getButtons() as $button) {
         array_set($button, 'entry', $entry);
         $button = $this->evaluator->evaluate($button, compact('entry', 'table'));
         $button = $this->parser->parse($button, $entry);
         $button = $this->value->replace($button, $entry);
         $button = $this->factory->make($button);
         if (!$button->isEnabled()) {
             continue;
         }
         $buttons->push($button);
     }
     return $buttons;
 }