本文整理汇总了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;
}
示例2: findOrFail
public function findOrFail($id)
{
$this->newQuery();
if ($result = $this->query->find($id)) {
return $result;
}
throw (new ModelNotFoundException())->setModel($this->model);
}
示例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;
}
示例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);
});
}
示例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));
}
示例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);
}
示例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);
}
示例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);
}
示例9: find
/**
* @param $id
* @param array $columns
* @return mixed
*/
public function find($id, $columns = array('*'))
{
return $this->query->find($id, $columns);
}
示例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);
}
示例11: findById
/**
* @param $id
* @return \Illuminate\Database\Eloquent\Collection|\Illuminate\Database\Eloquent\Model|null
*/
public function findById($id)
{
return $this->instance->find($id);
}
示例12: find
public function find($id)
{
return $this->version->find($id);
}
示例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);
}
示例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));
}
示例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);
}