當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。