本文整理汇总了PHP中Illuminate\Database\Eloquent\Builder::onlyTrashed方法的典型用法代码示例。如果您正苦于以下问题:PHP Builder::onlyTrashed方法的具体用法?PHP Builder::onlyTrashed怎么用?PHP Builder::onlyTrashed使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Database\Eloquent\Builder
的用法示例。
在下文中一共展示了Builder::onlyTrashed方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: applyFilters
private function applyFilters(Builder $query, $expression, $value, $multiple = false)
{
$equalsFilter = false;
$field = null;
$filter = explode(":", $expression);
// filter[field:filter]=value
if (count($filter) == 2) {
$field = $filter[0];
$filter = $filter[1];
} else {
$equalsFilter = true;
$field = $expression;
}
// filter[field]=value
if ($equalsFilter) {
$multiple ? $query->orWhere($field, '=', $value) : $query->where($field, '=', $value);
}
// filter[field:between]=A,B
if ($this->isBetweenFilter($filter)) {
$betweenValues = $this->getBetweenValues($value);
if (count($betweenValues) != 2) {
throw new BadRequestHttpException("Please specify two numbers to filter between");
}
$multiple ? $query->orWhereBetween($field, $betweenValues) : $query->whereBetween($field, $betweenValues);
}
// filter[field:[after, before, greater_than, less_than]]=value
if ($this->isComparisonFilter($filter)) {
if ($this->isDateFilter($field)) {
$value = Carbon::createFromTimestamp($value);
}
$comparisonFilter = $this->getComparisonFilter($filter);
$multiple ? $query->orWhere($field, $comparisonFilter, $value) : $query->where($field, $comparisonFilter, $value);
}
// filter[field:[contains, ends_with, starts_with]]=value
if ($this->isWildcardFilter($filter)) {
$value = $this->getLikeWildcard($filter, $value);
$multiple ? $query->orWere($field, 'like', $value) : $query->where($field, 'like', $value);
}
// filter[field:trashed]=true
if ($this->isTrashedFilter($field)) {
$query->onlyTrashed();
}
}
示例2: applySoftDeletesQuery
/**
* Apply soft-delete changes to the query.
*
* @param Model|Builder $query
* @return mixed
*/
protected function applySoftDeletesQuery($query)
{
if ($this->withTrashed === true) {
return $query->withTrashed();
} elseif ($this->onlyTrashed === true) {
return $query->onlyTrashed();
}
return $query;
}
示例3: startWithTrashedOnly
/**
* Reset and only includes soft deletes for following queries.
*
* @return $this
*/
public function startWithTrashedOnly()
{
/**
* Save to conditons.
*/
$this->addCondition('onlyTrashed', 'onlyTrashed');
$this->model = $this->model->onlyTrashed();
return $this;
}
示例4: startWithTrashedOnly
/**
* Reset and only includes soft deletes for following queries.
*
* @return $this
*/
public function startWithTrashedOnly()
{
$this->reset(new Action(__METHOD__, []));
/**
* Save to conditons.
*/
$this->addCondition('onlyTrashed', 'onlyTrashed');
$this->model = $this->model->onlyTrashed();
return $this;
}
示例5: scopeCancelled
/**
* Scope a query to only include activities that are cancelled/soft deleted.
*
* @param \Illuminate\Database\Eloquent\Builder $query the query to activities to be scoped
* @return \Illuminate\Database\Eloquent\Builder
*/
public function scopeCancelled($query)
{
$query->onlyTrashed()->latest('datetime_start');
}
示例6: handle
/**
* Handle the query.
*
* @param TableBuilder $builder
* @param Builder $query
*/
public function handle(TableBuilder $builder, Builder $query)
{
$query->onlyTrashed();
}