/** * Returns the default named scope that should be implicitly applied to all queries for this model. * @return array the query criteria. */ public function defaultScope() { $scope = parent::defaultScope(); if ($this->hasAttribute('status')) { $tableAlias = $this->getTableAlias(true, false); $condition = $tableAlias . '.status>=0'; $scope['condition'] = isset($scope['condition']) ? '(' . $scope['condition'] . ') AND (' . $condition . ')' : $condition; } return $scope; }
/** * Returns the default named scope that should be implicitly applied to all queries for this model. * @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; }
public function defaultScope() { parent::defaultScope(); return array('condition' => "post_type='post'"); }