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


PHP TableBuilder::fire方法代码示例

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


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

示例1: 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

示例2: 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

示例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: 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::fire方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。