本文整理汇总了PHP中Illuminate\Database\Eloquent\Builder::newQuery方法的典型用法代码示例。如果您正苦于以下问题:PHP Builder::newQuery方法的具体用法?PHP Builder::newQuery怎么用?PHP Builder::newQuery使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Database\Eloquent\Builder
的用法示例。
在下文中一共展示了Builder::newQuery方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: newQuery
/**
* @return Builder
*/
public function newQuery()
{
if (is_string($this->modelClass)) {
return (new $this->modelClass())->newQuery();
}
if ($this->modelClass instanceof Model) {
return $this->modelClass->newQuery();
}
return $this->modelClass;
}
示例2: resetQueryBuilder
/**
* @return $this
*/
public function resetQueryBuilder()
{
$this->specificationQuery = clone $this->table;
$this->specificationQuery = $this->specificationQuery->newQuery();
$this->specifications = [];
return $this;
}
示例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;
}
示例4: newQuery
/**
* @return $this
*/
public function newQuery()
{
$this->model = $this->model->newQuery();
return $this;
}