Model中声明
public function scopeIsClosed(Builder $query)
{
return $query->where('closed_at', '>', 0);
}
public function scopeNotClose(Builder $query)
{
return $query->where('closed_at', '=', 0);
}
业务使用
public function setHasHandled()
{
$this->query->scopes(['IsClosed']);
return $this;
}