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


PHP Builder::first方法代码示例

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


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

示例1: getByCredentials

 /**
  * @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();
 }
开发者ID:yayatoure42,项目名称:service-exchange,代码行数:12,代码来源:UserStorage.php

示例2: 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);
 }
开发者ID:arcstone,项目名称:eloquent-versioned,代码行数:12,代码来源:Builder.php

示例3: first

 /**
  * 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;
 }
开发者ID:edouardkombo,项目名称:spinv,代码行数:12,代码来源:BaseRepository.php

示例4: first

 /**
  * 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;
 }
开发者ID:kodebyraaet,项目名称:pattern,代码行数:13,代码来源:BaseRepository.php

示例5: getEntity

 /**
  * @return mixed|null
  */
 public function getEntity()
 {
     /** @var DoplioDbTable|null $result */
     $result = $this->specificationQuery->first();
     if (!$result) {
         return null;
     }
     return $this->mapper->fromDbTableRow($result);
 }
开发者ID:middleout,项目名称:doplio,代码行数:12,代码来源:AbstractRepository.php

示例6: update

 /**
  * @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;
 }
开发者ID:pointer-ba,项目名称:bundle,代码行数:32,代码来源:Repository.php

示例7: first

 /**
  * 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);
 }
开发者ID:satriashp,项目名称:tour,代码行数:11,代码来源:_ide_helper.php

示例8: first

 /**
  * Return the first entry.
  *
  * @param  array $columns
  * @return EloquentModel|EntryInterface
  */
 public function first(array $columns = ['*'])
 {
     return (new Decorator())->decorate($this->query->first($columns));
 }
开发者ID:huglester,项目名称:streams-platform,代码行数:10,代码来源:EloquentCriteria.php

示例9: first

 /**
  * @param Builder $builder
  * @return Model
  */
 protected function first(Builder $builder)
 {
     return $builder->first();
 }
开发者ID:cloudcreativity,项目名称:laravel-json-api,代码行数:8,代码来源:AbstractSearch.php

示例10: executeQuery

 /**
  * 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();
         });
     }
 }
开发者ID:pushoperations,项目名称:magician,代码行数:24,代码来源:Repository.php

示例11: first

 /**
  * @param array $columns
  * @return Model|Collection
  */
 public function first($columns = ['*'])
 {
     /** @var Model $result */
     $model = parent::first($columns);
     return $model ?: $this->model->newInstance([]);
 }
开发者ID:garrinar,项目名称:laravel,代码行数:10,代码来源:Builder.php


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