示例#1
0
 public function lettersUsage(Entity $entity, array $filters = [])
 {
     $collumn = $entity->letterCollumn();
     $query = $entity->newQuery()->selectRaw("{$collumn}, count(id) as count");
     foreach ($filters as $filter) {
         if ($filter != $this) {
             $query = $filter->applyFilterToQuery($query);
         }
     }
     $fetched = $query->groupBy($collumn)->orderBy($collumn)->lists('count', $collumn);
     $result = [];
     foreach ($fetched as $letter => $count) {
         preg_match('/(.)/iu', $letter, $match);
         $letter = mb_strtoupper($match[1]);
         $result[$letter] = (isset($result[$letter]) ? $result[$letter] : 0) + $count;
     }
     return $result;
 }
示例#2
0
 public function applyOrdering(Entity $entity)
 {
     $entity->underlyingQuery()->orderBy($this->collumn, $this->direction);
 }
示例#3
0
 public function applyFilter(Entity $entity)
 {
     $entity->underlyingQuery($this->applyFilterToQuery($entity->underlyingQuery()));
 }