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


PHP TableBuilder::getTableModel方法代码示例

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


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

示例1: handle

 /**
  * Handle the filter.
  *
  * @param Builder               $query
  * @param SearchFilterInterface $filter
  */
 public function handle(Builder $query, TableBuilder $builder, SearchFilterInterface $filter)
 {
     $stream = $filter->getStream();
     $model = $builder->getTableModel();
     /**
      * If the model is translatable then
      * join it's translations so they
      * are filterable too.
      *
      * @var EloquentQueryBuilder $query
      */
     if ($model->getTranslationModelName() && !$query->hasJoin($model->getTranslationTableName())) {
         $query->leftJoin($model->getTranslationTableName(), $model->getTableName() . '.id', '=', $model->getTranslationTableName() . '.' . $model->getRelationKey());
     }
     $query->where(function (Builder $query) use($filter, $stream) {
         foreach ($filter->getColumns() as $column) {
             $query->orWhere($column, 'LIKE', "%{$filter->getValue()}%");
         }
         foreach ($filter->getFields() as $field) {
             $filter->setField($field);
             $fieldType = $stream->getFieldType($field);
             $fieldTypeQuery = $fieldType->getQuery();
             $fieldTypeQuery->setConstraint('or');
             $this->container->call([$fieldTypeQuery, 'filter'], compact('query', 'filter', 'builder'));
         }
     });
 }
开发者ID:jacksun101,项目名称:streams-platform,代码行数:33,代码来源:SearchFilterQuery.php

示例2: handle

 /**
  * Handle the command.
  *
  * @param Container $container
  */
 public function handle(Container $container)
 {
     /**
      * Set the default options handler based
      * on the builder class. Defaulting to
      * no handler.
      */
     if (!$this->builder->getRepository()) {
         $model = $this->builder->getTableModel();
         if (!$this->builder->getRepository() && $model instanceof EntryModel) {
             $this->builder->setRepository($container->make(EntryTableRepository::class, compact('model')));
         } elseif (!$this->builder->getRepository() && $model instanceof EloquentModel) {
             $this->builder->setRepository($container->make(EloquentTableRepository::class, compact('model')));
         }
     }
 }
开发者ID:jacksun101,项目名称:streams-platform,代码行数:21,代码来源:SetRepository.php

示例3: handle

 /**
  * Save the order of the entries.
  *
  * @param TableBuilder $builder
  * @param Request      $request
  */
 public function handle(TableBuilder $builder, Request $request)
 {
     $count = 0;
     $model = $builder->getTableModel();
     /* @var EloquentModel $entry */
     foreach ($request->get($builder->getTableOption('prefix') . 'order', []) as $k => $id) {
         if ($entry = $model->find($id)) {
             $entry->sort_order = $k + 1;
             $entry->save();
             $count++;
         }
     }
     $builder->fire('reordered', compact('count', 'builder'));
     $this->messages->success(trans('streams::message.reorder_success', compact('count')));
 }
开发者ID:jacksun101,项目名称:streams-platform,代码行数:21,代码来源:Reorder.php

示例4: handle

 /**
  * ExportAll the selected entries.
  *
  * @param TableBuilder    $builder
  * @param ResponseFactory $response
  * @param array           $selected
  */
 public function handle(TableBuilder $builder, ResponseFactory $response, array $selected)
 {
     $model = $builder->getTableModel();
     $stream = $builder->getTableStream();
     $headers = ['Content-Disposition' => 'attachment; filename=' . $stream->getSlug() . '.csv', 'Cache-Control' => 'must-revalidate, post-check=0, pre-check=0', 'Content-type' => 'text/csv', 'Pragma' => 'public', 'Expires' => '0'];
     $callback = function () use($selected, $model) {
         $output = fopen('php://output', 'w');
         /* @var EloquentModel $entry */
         foreach ($model->all() as $k => $entry) {
             if ($k == 0) {
                 fputcsv($output, array_keys($entry->toArray()));
             }
             fputcsv($output, $entry->toArray());
         }
         fclose($output);
     };
     $builder->setTableResponse($response->stream($callback, 200, $headers));
 }
开发者ID:jacksun101,项目名称:streams-platform,代码行数:25,代码来源:ExportAll.php

示例5: handle

 /**
  * Delete the selected entries.
  *
  * @param TableBuilder $builder
  * @param array        $selected
  */
 public function handle(TableBuilder $builder, array $selected)
 {
     $count = 0;
     $model = $builder->getTableModel();
     /* @var EloquentModel $entry */
     foreach ($selected as $id) {
         $entry = $model->find($id);
         if ($entry && $entry->isDeletable() && $entry->delete()) {
             $builder->fire('row_deleted', compact('builder', 'model', 'entry'));
             $count++;
         }
     }
     if ($count) {
         $builder->fire('rows_deleted', compact('count', 'builder', 'model'));
     }
     if ($selected) {
         $this->messages->success(trans('streams::message.delete_success', compact('count')));
     }
 }
开发者ID:huglester,项目名称:streams-platform,代码行数:25,代码来源:Delete.php

示例6: handle

 /**
  * ForceDelete the selected entries.
  *
  * @param TableBuilder $builder
  * @param array        $selected
  */
 public function handle(TableBuilder $builder, EloquentRepositoryInterface $repository, array $selected)
 {
     $count = 0;
     $repository->setModel($builder->getTableModel());
     /* @var EloquentModel $entry */
     foreach ($selected as $id) {
         if ($entry = $repository->findTrashed($id)) {
             if ($entry->trashed() && $repository->forceDelete($entry)) {
                 $builder->fire('row_deleted', compact('builder', 'model', 'entry'));
                 $count++;
             }
         }
     }
     if ($count) {
         $builder->fire('rows_deleted', compact('count', 'builder', 'model'));
     }
     if ($selected) {
         $this->messages->success(trans('streams::message.delete_success', compact('count')));
     }
 }
开发者ID:huglester,项目名称:streams-platform,代码行数:26,代码来源:ForceDelete.php


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