Code

< 40 %
40-60 %
> 60 %
1
<?php
2
/**
3
 * @link https://github.com/paulzi/yii2-nested-intervals
4
 * @copyright Copyright (c) 2015 PaulZi <[email protected]>
5
 * @license MIT (https://github.com/paulzi/yii2-nested-intervals/blob/master/LICENSE)
6
 */
7
8
namespace paulzi\nestedintervals;
9
10
/**
11
 * @author PaulZi <[email protected]>
12
 */
13
trait NestedIntervalsQueryTrait
14
{
15
    /**
16
     * @return \yii\db\ActiveQuery
17
     */
18 3
    public function roots()
19
    {
20
        /** @var \yii\db\ActiveQuery $this */
21 3
        $class = $this->modelClass;
22 3
        $model = new $class;
23 3
        return $this->andWhere([$model->leftAttribute => $model->range[0]]);
24
    }
25
}
26