本文整理匯總了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;
}