/** * @inheritdoc */ public function getByCredentials(array $credentials) { foreach ($credentials as $key => $value) { if (strpos($key, 'password') === false) { $this->queryBuilder->where($key, $value); } } return $this->queryBuilder->first(); }
/** * @param array $columns * * @return \Illuminate\Database\Eloquent\Model|null|static */ public function first($columns = array('*')) { if (count($this->query->orders) == 0) { $this->orderBy(static::COLUMN_MODEL_ID); } return parent::first($columns); }
/** * Get the first specified model record from the database * * @return \Illuminate\Database\Eloquent\Model */ public function first() { $this->newQuery()->eagerLoad()->setClauses(); $model = $this->query->first(); $this->unsetClauses(); return $model; }
/** * Return the first element * * @return Collection */ public function first() { // Save the results from the builder $result = $this->builder->first(); // Reset the builder, just in case we are going to use this repository more then once $this->newBuilder(); return $result; }
/** * @return mixed|null */ public function getEntity() { /** @var DoplioDbTable|null $result */ $result = $this->specificationQuery->first(); if (!$result) { return null; } return $this->mapper->fromDbTableRow($result); }
/** * @param $id * @param $data * @param bool $orFail * @return mixed * * updates an existing record */ public function update($id, $data, $orFail = false) { if ($id instanceof Model) { $this->model = $id; } else { $this->model = new $this->modelClass(); $table = $this->model->getTable(); $this->model = $this->model->newQuery(); $this->model->where($table . '.' . $this->identifier, '=', $id); $this->model = $orFail ? $this->model->firstOrFail() : $this->model->first(); if (!$this->model) { return false; } } if (!is_array($data)) { $data = $this->extractData($data); } $this->model->fill($data); foreach ($this->updateDefaults() as $key => $value) { $this->model->{$key} = $value; } $this->model->save(); return $this->model; }
/** * Execute the query and get the first result. * * @param array $columns * @return \Illuminate\Database\Eloquent\Model|static|null * @static */ public static function first($columns = array()) { return \Illuminate\Database\Eloquent\Builder::first($columns); }
/** * Return the first entry. * * @param array $columns * @return EloquentModel|EntryInterface */ public function first(array $columns = ['*']) { return (new Decorator())->decorate($this->query->first($columns)); }
/** * @param Builder $builder * @return Model */ protected function first(Builder $builder) { return $builder->first(); }
/** * Query execution function called by getters. * All repository getters should call this for integrated caching at the repository level. * * @param \Illuminate\Database\Eloquent\Builder $query * @param array $columns The columns to retrieve * @param bool $first Limit to one result or not * @return \Illuminate\Support\Collection|\Illuminate\Database\Eloquent\Model|null */ protected function executeQuery($query, $first) { $tag = $this->cacheTag ?: $this->untagged; $builder = $query->getQuery(); $key = $this->getQueryKey($builder, $first); if ($first) { return Cache::tags(['repositories', $tag])->remember($key, $this->cacheDuration, function () use($query) { return $query->first(); }); } else { return Cache::tags(['repositories', $tag])->remember($key, $this->cacheDuration, function () use($query) { return $query->get(); }); } }
/** * @param array $columns * @return Model|Collection */ public function first($columns = ['*']) { /** @var Model $result */ $model = parent::first($columns); return $model ?: $this->model->newInstance([]); }