コード例 #1
1
 /**
  * Get records from the database.
  *
  * @param int $per_page
  *
  * @return Collection
  */
 public function get($per_page = 20)
 {
     $this->per_page = $per_page;
     $this->buildQuery();
     return $this->query->get();
 }
コード例 #2
0
 /**
  * Get the results for the model.
  *
  * @return array
  * @throws ModelNotSetException
  */
 public function results()
 {
     if (!$this->model) {
         throw new ModelNotSetException('You must set a model to be used by the eloquent driver.');
     }
     return $this->model->get($this->select)->all();
 }
コード例 #3
0
 /**
  * @param array $with
  * @return Collection
  */
 public function all(array $with = array())
 {
     $this->addWithCriteria($with);
     $this->applyCriteria();
     $result = $this->model->get();
     $this->refresh();
     return $result;
 }
コード例 #4
0
 /**
  * Return all instances of the model.
  *
  * @param array $columns
  * return \Illuminate\Database\Eloquent\Model
  */
 public function all($columns = array('*'))
 {
     $key = snake_case(class_basename($this) . '_' . __FUNCTION__);
     if (Cache::has($key)) {
         return Cache::get($key);
     }
     $result = $this->model->get($columns);
     Cache::add($key, $result, env('APP_CACHE_MINUTES'));
     return $result;
 }
コード例 #5
0
ファイル: BaseRepository.php プロジェクト: thinktomorrow/repo
 /**
  * Base fetch for all repository returns
  * This should be used when returning multiple records
  *
  * @param  Model $model - update model instance
  * @return Illuminate\Database\Eloquent\Collection
  */
 public function fetch($model = null)
 {
     if (!is_null($model)) {
         $this->model = $model;
     }
     $result = $this->paginated && is_int($this->paginated) ? $this->model->paginate($this->paginated) : $this->model->get();
     if ($this->paginated) {
         // Append custom query string to page links to maintain correct url filter and sorting
         $result = $result->appends($this->buildUrlQuery());
     }
     $this->reset();
     return $result;
 }
コード例 #6
0
 /**
  * Find data by multiple fields
  *
  * @param array $where
  * @param array $columns
  * @return mixed|Model
  */
 public function findWhere(array $where, $columns = ['*'])
 {
     return $this->wrap(function ($where, $columns = ['*']) {
         $this->applyWhere($where);
         return $this->model->get($columns);
     }, new Action(__METHOD__, func_get_args(), Action::READ));
 }
コード例 #7
0
 /**
  * Find data by Criteria
  *
  * @param CriteriaInterface $criteria
  *
  * @return mixed
  */
 public function getByCriteria(CriteriaInterface $criteria)
 {
     $this->model = $criteria->apply($this->model, $this);
     $results = $this->model->get();
     $this->resetModel();
     return $this->parserResult($results);
 }
コード例 #8
0
ファイル: Repository.php プロジェクト: lfalmeida/lbase
 /**
  * Retorna todos os registros deste Model.
  *
  * @param array $columns Colunas desejadas no retorno.
  *
  * @return mixed
  */
 public function all($columns = ['*'])
 {
     if (!empty($this->defaultOrderColumn)) {
         return $this->model->orderBy($this->defaultOrderColumn, $this->defaultOrderDirection)->get($columns);
     }
     return $this->model->get($columns);
 }
コード例 #9
0
ファイル: BaseRepository.php プロジェクト: killtw/repository
 /**
  * @param CriteriaInterface|string $criteria
  *
  * @return Collection
  */
 public function getByCriteria($criteria)
 {
     if (is_string($criteria)) {
         $criteria = $this->app->make($criteria);
     }
     $this->model = $criteria->apply($this->model, $this);
     $results = $this->model->get();
     $this->resetModel();
     return $this->parseResult($results);
 }
コード例 #10
0
 /**
  * @param array $columns
  * @return mixed
  */
 public function get($columns = ['*'])
 {
     $this->applyBoot();
     $this->applyScopes();
     $this->applyCriteria();
     if ($this->model instanceof Builder) {
         $results = $this->model->get($columns);
     } else {
         $results = $this->model->all($columns);
     }
     $this->cleanRepository();
     return $results;
 }
コード例 #11
0
 /**
  * Find data by multiple fields.
  *
  * @param array $where
  * @param array $columns
  *
  * @return mixed
  */
 public function findWhere(array $where, $columns = ['*'])
 {
     foreach ($where as $field => $value) {
         if (is_array($value)) {
             list($field, $condition, $val) = $value;
             $this->model = $this->model->where($field, $condition, $val);
         } else {
             $this->model = $this->model->where($field, '=', $value);
         }
     }
     $model = $this->model->get($columns);
     $this->resetModel();
     return $model;
 }
コード例 #12
0
 /**
  * Find data by multiple Criterias
  *
  * @param array $criterias
  * @return mixed
  * @public param \Prettus\Repository\Contracts\CriteriaInterface[] $criteria
  */
 public function getByAdditionalCriterias(array $criterias)
 {
     $current_criteria = $this->getCriteria();
     if ($current_criteria) {
         foreach ($current_criteria as $c) {
             if ($c instanceof CriteriaInterface) {
                 $this->model = $c->apply($this->model, $this);
             }
         }
     }
     foreach ($criterias as $c) {
         if ($c instanceof CriteriaInterface) {
             $this->model = $c->apply($this->model, $this);
         }
     }
     $results = $this->model->get();
     $this->resetModel();
     return $this->parserResult($results);
 }
コード例 #13
0
 /**
  * @param array $columns
  * @return mixed
  */
 public function random($columns = array('*'))
 {
     return $this->model->get()->random();
 }
コード例 #14
0
 /**
  * Displays all the items
  */
 public function getIndex()
 {
     $items = $this->model->get();
     return $this->render('index', compact('items'))->with('columns', $this->tableColumns);
 }
コード例 #15
0
ファイル: Repofuck.php プロジェクト: prjkt/repofuck
 /**
  * Gets an entity by parameters
  *
  * @return \Illuminate\Database\Eloquent\Collection
  */
 public function get() : Collection
 {
     return $this->entity->get();
 }
コード例 #16
0
 /**
  * Retrieves all records from storage
  * 
  * @param  array $col
  * @return Illuminate\Support\Collection      
  */
 public function getAll($col = ['*'])
 {
     return $this->model->get($col);
 }
コード例 #17
0
ファイル: RepositoryBase.php プロジェクト: logaretm/depo
 /**
  * Gets all repository model data ignoring query scopes.
  *
  * @param array $columns
  * @return mixed
  */
 public function all($columns = array('*'))
 {
     return $this->model->get($columns);
 }
コード例 #18
0
ファイル: EloquentTable.php プロジェクト: zhwei/laravel-lego
 /**
  * 处理上方所有条件后, 执行查询语句, 返回结果集
  *
  * @param array $columns 默认获取全部字段
  * @return mixed
  */
 protected function selectQuery(array $columns = []) : \Illuminate\Support\Collection
 {
     return $this->original->get($columns);
 }
コード例 #19
0
 /**
  * Get the collection of model.
  *
  * @param array $columns
  * @return \Illuminate\Database\Eloquent\Collection
  */
 public function all($columns = ['*'])
 {
     return $this->model->get($columns);
 }
コード例 #20
0
 /**
  * Return all the records in the repo
  *
  * @return \Illuminate\Database\Eloquent\Collection
  */
 public function getAll()
 {
     return $this->model->get();
 }
コード例 #21
0
 /**
  * @return mixed
  */
 public function results()
 {
     return $this->model->get()->toArray();
 }
コード例 #22
0
 /**
  * Perform counter caching on all entities of model.
  *
  * @author Morten Rugaard <*****@*****.**>
  *
  * @param  \Illuminate\Database\Eloquent\Model $model
  * @return bool
  * @throws \Nodes\CounterCache\Exceptions\NoEntitiesFoundException
  * @throws \Nodes\CounterCache\Exceptions\NoCounterCachesFound
  * @throws \Nodes\CounterCache\Exceptions\NotCounterCacheableException
  * @throws \Nodes\CounterCache\Exceptions\RelationNotFoundException
  */
 public function countAll(IlluminateModel $model)
 {
     // Retrieve all entities of model
     $entities = $model->get();
     // If no entities found, we'll log the error,
     // throw an exception and abort.
     if (!$entities->isEmpty()) {
         Log::error(sprintf('[%s] No entities found of model [%s]', __CLASS__, get_class($model)));
         throw new NoEntitiesFoundException(sprintf('No entities found of model [%s]', get_class($model)));
     }
     // Perform counter caching on each found entity
     foreach ($entities as $entry) {
         $this->count($entry);
     }
     return true;
 }
コード例 #23
0
 /**
  * Get all models from the database.
  *
  * @param  array $columns
  * @return \Illuminate\Database\Eloquent\Collection
  */
 public function all($columns = ['*'])
 {
     $results = $this->model->get($columns);
     $this->reset();
     return $this->hookAll($results);
 }