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


PHP Builder::find方法代码示例

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


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

示例1: update

 /**
  * Update an item
  *
  * @param integer $id
  * @param array   $data
  * @return mixed
  */
 public function update($id, array $data)
 {
     $item = $this->builder->find($id);
     $item->update($data);
     // Reset the query builder
     $this->newBuilder();
     return $item;
 }
开发者ID:kodebyraaet,项目名称:pattern,代码行数:15,代码来源:BaseRepository.php

示例2: findOrFail

 public function findOrFail($id)
 {
     $this->newQuery();
     if ($result = $this->query->find($id)) {
         return $result;
     }
     throw (new ModelNotFoundException())->setModel($this->model);
 }
开发者ID:sthWrong,项目名称:season5.co,代码行数:8,代码来源:AbstractRepository.php

示例3: scopeValidOrFail

 /**
  * Find the token with the given ID, and assert that it has not expired.
  *
  * @param \Illuminate\Database\Eloquent\Builder $query
  * @param string $id
  * @return static
  * @throws InvalidConfirmationTokenException
  */
 public function scopeValidOrFail($query, $id)
 {
     $token = $query->find($id);
     if (!$token || $token->created_at < new DateTime('-1 day')) {
         throw new InvalidConfirmationTokenException();
     }
     return $token;
 }
开发者ID:flarum,项目名称:core,代码行数:16,代码来源:EmailToken.php

示例4: find

 /**
  * Find a model by its primary key.
  *
  * @param mixed $id
  * @param array $columns
  *
  * @return \Illuminate\Database\Eloquent\Model|\Illuminate\Database\Eloquent\Collection|null
  */
 public function find($id, $columns = ['*'])
 {
     if (is_array($id)) {
         return $this->findMany($id, $columns);
     }
     return Cache::tags($this->model->getTable())->remember($id, $this->model->cacheExpiry, function () use($id, $columns) {
         return parent::find($id, $columns);
     });
 }
开发者ID:tshafer,项目名称:laravel-traits,代码行数:17,代码来源:Builder.php

示例5: find

 /**
  * @param $id
  * @param array $columns
  * @return mixed
  */
 public function find($id, $columns = array('*'))
 {
     $this->applyCriteria();
     return $this->execute($this->model->find($id, $columns));
 }
开发者ID:DiSiqueira,项目名称:TheOscars,代码行数:10,代码来源:Repository.php

示例6: find

 /**
  * @param $id
  * @param array $columns
  * @return mixed
  */
 public function find($id, $columns = array('*'))
 {
     $this->applyCriteria();
     $this->newQuery()->eagerLoadRelations();
     return $this->model->find($id, $columns);
 }
开发者ID:jonphipps,项目名称:Repositories,代码行数:11,代码来源:Repository.php

示例7: getById

 /**
  * Get the specified model record from the database
  *
  * @param $id
  *
  * @return \Illuminate\Database\Eloquent\Model
  */
 public function getById($id)
 {
     $this->unsetClauses();
     $this->newQuery()->eagerLoad();
     return $this->query->find($id);
 }
开发者ID:edouardkombo,项目名称:spinv,代码行数:13,代码来源:BaseRepository.php

示例8: find

 /**
  * Find notification by id
  *
  * @param $notification_id
  * @return \Illuminate\Database\Eloquent\Collection|\Illuminate\Database\Eloquent\Model|static
  */
 public function find($notification_id)
 {
     return $this->notification->find($notification_id);
 }
开发者ID:naimkhalifa,项目名称:Notifynder,代码行数:10,代码来源:NotificationRepository.php

示例9: find

 /**
  * @param $id
  * @param array $columns
  * @return mixed
  */
 public function find($id, $columns = array('*'))
 {
     return $this->query->find($id, $columns);
 }
开发者ID:gdgfoz,项目名称:codelab-todo-api,代码行数:9,代码来源:BaseRepository.php

示例10: find

 /**
  * Find a record
  *
  * @param int   $id
  * @param array $columns
  * @return \Illuminate\Database\Eloquent\Model
  */
 public function find($id, $columns = ['*'])
 {
     return $this->builder->find($id, $columns);
 }
开发者ID:renatogcarvalho,项目名称:feeder,代码行数:11,代码来源:Repository.php

示例11: findById

 /**
  * @param $id
  * @return \Illuminate\Database\Eloquent\Collection|\Illuminate\Database\Eloquent\Model|null
  */
 public function findById($id)
 {
     return $this->instance->find($id);
 }
开发者ID:az-iar,项目名称:repository,代码行数:8,代码来源:BaseRepository.php

示例12: find

 public function find($id)
 {
     return $this->version->find($id);
 }
开发者ID:laravelflare,项目名称:versioning,代码行数:4,代码来源:VersionRepository.php

示例13: updateModerationStatus

 /**
  * @param \Illuminate\Database\Eloquent\Builder $builder
  * @param $id
  * @param $status
  *
  * @return bool|int
  */
 private function updateModerationStatus(Builder $builder, $id, $status)
 {
     //If $id parameter is passed then update the specified model
     if ($id) {
         $model = $builder->find($id);
         $model->{$model->getStatusColumn()} = $status;
         $model->{$model->getModeratedAtColumn()} = Carbon::now();
         //if moderated_by in enabled then append it to the update
         if ($moderated_by = $model->getModeratedByColumn()) {
             $model->{$moderated_by} = \Auth::user()->getKey();
         }
         $model->save();
         return $model;
     }
     $update = [$builder->getModel()->getStatusColumn() => $status, $builder->getModel()->getModeratedAtColumn() => Carbon::now()];
     //if moderated_by in enabled then append it to the update
     if ($moderated_by = $builder->getModel()->getModeratedByColumn()) {
         $update[$builder->getModel()->getModeratedByColumn()] = \Auth::user()->getKey();
     }
     return $builder->update($update);
 }
开发者ID:hootlex,项目名称:laravel-moderation,代码行数:28,代码来源:ModerationScope.php

示例14: find

 /**
  * Find an entry.
  *
  * @param                           $identifier
  * @param  array                    $columns
  * @return Presenter|EntryPresenter
  */
 public function find($identifier, array $columns = ['*'])
 {
     return (new Decorator())->decorate($this->query->find($identifier, $columns));
 }
开发者ID:huglester,项目名称:streams-platform,代码行数:11,代码来源:EloquentCriteria.php

示例15: find

 /**
  * Find a group by ID
  *
  * @param $group_id
  * @return \Illuminate\Database\Eloquent\Collection|\Illuminate\Database\Eloquent\Model|static
  */
 public function find($group_id)
 {
     return $this->groupModel->find($group_id);
 }
开发者ID:subasioguz,项目名称:Notifynder,代码行数:10,代码来源:GroupRepository.php


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