NestedSetsQueryBehavior
API reference › Nested sets behavior › NestedSetsQueryBehavior
Adds root and leaf queries to an ActiveQuery whose model is managed by NestedSetsBehavior.
Properties
Section titled “Properties”| Property | Type | Description | Defined by |
|---|---|---|---|
$owner | yii\ | The owner of this behavior Default: null. | yii\ |
Methods
Section titled “Methods”| Method | Description | Defined by |
|---|---|---|
__construct() | Constructor. | yii\ |
__call() | Calls the named method which is not a class method. | yii\ |
__get() | Returns the value of an object property. | yii\ |
__isset() | Checks if a property is set, i.e. defined and not null. | yii\ |
__set() | Sets value of an object property. | yii\ |
__unset() | Sets an object property to null. | yii\ |
attach() | Attaches the behavior object to the component. | yii\ |
canGetProperty() | Returns a value indicating whether a property can be read. | yii\ |
canSetProperty() | Returns a value indicating whether a property can be set. | yii\ |
className() static | Returns the fully qualified name of this class. | yii\ |
detach() | Detaches the behavior object from the component. | yii\ |
events() | Declares event handlers for the $owner’s events. | yii\ |
hasMethod() | Returns a value indicating whether a method is defined. | yii\ |
hasProperty() | Returns a value indicating whether a property is defined. | yii\ |
init() | Initializes the object. | yii\ |
leaves() | Restricts the owner query to leaf nodes, ordered by tree identifier when enabled and then by left value. | NestedSetsQueryBehavior |
roots() | Restricts the owner query to root nodes, ordered by tree identifier when enabled and then by left value. | NestedSetsQueryBehavior |
Method details
Section titled “Method details”leaves()
Section titled “leaves() ”public function leaves(): yii2\extensions\nestedsets\TRestricts the owner query to leaf nodes, ordered by tree identifier when enabled and then by left value.
Returns
yii2\extensions\nestedsets\T: Owner query with the leaf condition and ordering applied.
Throws
LogicException: if the behavior is not attached or the query model is not anActiveRecord.
roots()
Section titled “roots() ”public function roots(): yii2\extensions\nestedsets\TRestricts the owner query to root nodes, ordered by tree identifier when enabled and then by left value.
Returns
yii2\extensions\nestedsets\T: Owner query with the root condition and ordering applied.
Throws
LogicException: if the behavior is not attached or the query model is not anActiveRecord.