Exemple #1
0
 /**
  * @param ModelWithOrderFieldInterface $instance
  * @param $totalCount
  * @return string
  */
 protected function moveButtons(ModelWithOrderFieldInterface $instance, $totalCount)
 {
     $sort = $instance->getOrderValue();
     $buttons = [];
     if ($sort > 0) {
         $buttons[] = $this->moveButton($this->router->routeToMoveup($this->modelItem->getAlias(), $instance->getKey()), Lang::get('admin::lang.table.moveUp'), '↑');
     }
     if ($sort < $totalCount - 1) {
         $buttons[] = $this->moveButton($this->router->routeToMovedown($this->modelItem->getAlias(), $instance->getKey()), Lang::get('admin::lang.table.moveDown'), '&darr;');
     }
     return implode(' ', $buttons);
 }
Exemple #2
0
 /**
  * @param WithJoinEloquentBuilder $originalQuery
  * @param $search
  * @internal param $query
  */
 protected function addSearchToQuery(WithJoinEloquentBuilder $originalQuery, $search)
 {
     $originalQuery->getQuery()->whereNested(function (Builder $query) use($search, $originalQuery) {
         $table = $this->instance->getTable();
         $columns = $this->getColumns($table);
         foreach ($columns as $column => $type) {
             $field = implode('.', [$table, $column]);
             if ($this->isDateColumn($type)) {
                 $field = DB::raw('convert(' . $field . ' using utf8)');
             }
             $query->orWhere($field, 'like', $search);
         }
         /** @var ColumnInterface[] $displayColumns */
         $displayColumns = $this->modelItem->getColumns();
         foreach ($displayColumns as $column) {
             $name = $column->getName();
             if (strpos($name, '.') !== false && $this->inWith($name, $originalQuery) && $this->modelItem->isWithJoinEnabled()) {
                 $query->orWhere($name, 'like', $search);
             }
         }
     });
 }