當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Builder::firstOrFail方法代碼示例

本文整理匯總了PHP中Illuminate\Database\Eloquent\Builder::firstOrFail方法的典型用法代碼示例。如果您正苦於以下問題:PHP Builder::firstOrFail方法的具體用法?PHP Builder::firstOrFail怎麽用?PHP Builder::firstOrFail使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Illuminate\Database\Eloquent\Builder的用法示例。


在下文中一共展示了Builder::firstOrFail方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: first

 /**
  * Get the first specified model record from the database
  *
  * @return \Illuminate\Database\Eloquent\Model
  */
 public function first()
 {
     $this->newQuery()->eagerLoad()->setClauses()->setScopes();
     $model = $this->query->firstOrFail();
     $this->unsetClauses();
     return $model;
 }
開發者ID:Okipa,項目名稱:una.app,代碼行數:12,代碼來源:BaseRepository.php

示例2: searchFor

 /**
  * @param       $value
  * @param array $in
  * @return Model
  */
 public function searchFor($value, array $in)
 {
     foreach ($in as $key) {
         $this->model = $this->model->orWhere($key, $value);
     }
     return $this->model->firstOrFail();
 }
開發者ID:crip-laravel,項目名稱:core,代碼行數:12,代碼來源:Repository.php

示例3: 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

示例4: firstOrFail

 /**
  * Execute the query and get the first result or throw an exception.
  *
  * @param array $columns
  * @return \Illuminate\Database\Eloquent\Model|static 
  * @throws \Illuminate\Database\Eloquent\ModelNotFoundException
  * @static 
  */
 public static function firstOrFail($columns = array())
 {
     return \Illuminate\Database\Eloquent\Builder::firstOrFail($columns);
 }
開發者ID:satriashp,項目名稱:tour,代碼行數:12,代碼來源:_ide_helper.php

示例5: first

 /**
  * @param array $columns
  * @return mixed
  */
 public function first()
 {
     $this->applyCriteria();
     return $this->execute($this->model->firstOrFail());
 }
開發者ID:DiSiqueira,項目名稱:TheOscars,代碼行數:9,代碼來源:Repository.php


注:本文中的Illuminate\Database\Eloquent\Builder::firstOrFail方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。