当前位置: 首页>>代码示例>>PHP>>正文


PHP TableBuilder::setTableOption方法代码示例

本文整理汇总了PHP中Anomaly\Streams\Platform\Ui\Table\TableBuilder::setTableOption方法的典型用法代码示例。如果您正苦于以下问题:PHP TableBuilder::setTableOption方法的具体用法?PHP TableBuilder::setTableOption怎么用?PHP TableBuilder::setTableOption使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Anomaly\Streams\Platform\Ui\Table\TableBuilder的用法示例。


在下文中一共展示了TableBuilder::setTableOption方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: handle

 /**
  * Handle the command.
  */
 public function handle()
 {
     $stream = $this->builder->getTableStream();
     if (!$stream instanceof StreamInterface) {
         return;
     }
     $eager = [];
     if ($stream->isTranslatable()) {
         $eager[] = 'translations';
     }
     $assignments = $stream->getRelationshipAssignments();
     foreach ($this->builder->getColumns() as $column) {
         /**
          * If the column value is a string and uses a dot
          * format then check if it's a relation.
          */
         if (isset($column['value']) && is_string($column['value']) && preg_match("/^entry.([a-zA-Z\\_]+)./", $column['value'], $match)) {
             if ($assignment = $assignments->findByFieldSlug($match[1])) {
                 if ($assignment->getFieldType()->getNamespace() == 'anomaly.field_type.polymorphic') {
                     continue;
                 }
                 $eager[] = camel_case($match[1]);
             }
         }
     }
     $this->builder->setTableOption('eager', array_unique($this->builder->getTableOption('eager', []) + $eager));
 }
开发者ID:jacksun101,项目名称:streams-platform,代码行数:30,代码来源:EagerLoadRelations.php

示例2: handle

 /**
  * Handle the command.
  *
  * @param Resolver  $resolver
  * @param Evaluator $evaluator
  */
 public function handle(Resolver $resolver, Evaluator $evaluator)
 {
     $evaluator->evaluate($resolver->resolve($this->builder->getOptions(), ['builder' => $this->builder]), ['builder' => $this->builder]);
     foreach ($this->builder->getOptions() as $key => $value) {
         $this->builder->setTableOption($key, $value);
     }
 }
开发者ID:jacksun101,项目名称:streams-platform,代码行数:13,代码来源:SetTableOptions.php

示例3: get

 /**
  * Get the table entries.
  *
  * @param  TableBuilder $builder
  * @return Collection
  */
 public function get(TableBuilder $builder)
 {
     // Grab any stream we have.
     $stream = $builder->getTableStream();
     // Start a new query.
     $query = $this->model->newQuery();
     /*
      * Prevent joins from overriding intended columns
      * by prefixing with the model's table name.
      */
     $query = $query->select($this->model->getTable() . '.*');
     /*
      * Eager load any relations to
      * save resources and queries.
      */
     $query = $query->with($builder->getTableOption('eager', []));
     /*
      * Raise and fire an event here to allow
      * other things (including filters / views)
      * to modify the query before proceeding.
      */
     $builder->fire('querying', compact('builder', 'query'));
     app('events')->fire(new TableIsQuerying($builder, $query));
     /*
      * Before we actually adjust the baseline query
      * set the total amount of entries possible back
      * on the table so it can be used later.
      */
     $total = $query->count();
     $builder->setTableOption('total_results', $total);
     /*
      * Assure that our page exists. If the page does
      * not exist then start walking backwards until
      * we find a page that is has something to show us.
      */
     $limit = (int) $builder->getTableOption('limit', config('streams::system.per_page', 15));
     $page = app('request')->get($builder->getTableOption('prefix') . 'page', 1);
     $offset = $limit * ($page - 1);
     if ($total < $offset && $page > 1) {
         $url = str_replace($builder->getTableOption('prefix') . 'page=' . $page, $builder->getTableOption('prefix') . 'page=' . ($page - 1), app('request')->fullUrl());
         header('Location: ' . $url);
     }
     /*
      * Limit the results to the limit and offset
      * based on the page if any.
      */
     $offset = $limit * (app('request')->get($builder->getTableOption('prefix') . 'page', 1) - 1);
     $query = $query->take($limit)->offset($offset);
     /*
      * Order the query results.
      */
     if ($order = $builder->getTableOption('order_by')) {
         foreach ($order as $column => $direction) {
             if ($stream && ($utility = $stream->getFieldTypeQuery($column))) {
                 $utility->orderBy($query, $direction);
             } else {
                 $query = $query->orderBy($column, $direction);
             }
         }
     }
     if ($builder->getTableOption('sortable')) {
         $query = $query->orderBy('sort_order', 'ASC');
     }
     return $query->get();
 }
开发者ID:huglester,项目名称:streams-platform,代码行数:71,代码来源:EloquentTableRepository.php


注:本文中的Anomaly\Streams\Platform\Ui\Table\TableBuilder::setTableOption方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。