ActiveRecord::defaultScope PHP Method

defaultScope() public method

Returns the default named scope that should be implicitly applied to all queries for this model.
public defaultScope ( ) : array
return array the query criteria.
    public function defaultScope()
    {
        $scope = parent::defaultScope();
        if ($this->hasAttribute('status')) {
            $tableAlias = $this->getTableAlias(true, false);
            $condition = $tableAlias . '.status >= 0';
            if (isset($scope['condition'])) {
                if (strpos($scope['condition'], 'status') === false) {
                    $scope['condition'] = '(' . $scope['condition'] . ') AND (' . $condition . ')';
                }
            } else {
                $scope['condition'] = $condition;
            }
        }
        return $scope;
    }