@@ 268-284 (lines=17) @@ | ||
265 | * @return \yii\db\ActiveQuery |
|
266 | * @throws NotSupportedException |
|
267 | */ |
|
268 | public function getPrev() |
|
269 | { |
|
270 | if ($this->sortable === false) { |
|
271 | throw new NotSupportedException('prev() not allow if not set sortable'); |
|
272 | } |
|
273 | $tableName = $this->owner->tableName(); |
|
274 | $query = $this->owner->find() |
|
275 | ->andWhere([ |
|
276 | 'and', |
|
277 | ["{$tableName}.[[{$this->parentAttribute}]]" => $this->owner->getAttribute($this->parentAttribute)], |
|
278 | ['<', "{$tableName}.[[{$this->behavior->sortAttribute}]]", $this->owner->getSortablePosition()], |
|
279 | ]) |
|
280 | ->orderBy(["{$tableName}.[[{$this->behavior->sortAttribute}]]" => SORT_DESC]) |
|
281 | ->limit(1); |
|
282 | $query->multiple = false; |
|
283 | return $query; |
|
284 | } |
|
285 | ||
286 | /** |
|
287 | * @return \yii\db\ActiveQuery |
|
@@ 290-306 (lines=17) @@ | ||
287 | * @return \yii\db\ActiveQuery |
|
288 | * @throws NotSupportedException |
|
289 | */ |
|
290 | public function getNext() |
|
291 | { |
|
292 | if ($this->sortable === false) { |
|
293 | throw new NotSupportedException('next() not allow if not set sortable'); |
|
294 | } |
|
295 | $tableName = $this->owner->tableName(); |
|
296 | $query = $this->owner->find() |
|
297 | ->andWhere([ |
|
298 | 'and', |
|
299 | ["{$tableName}.[[{$this->parentAttribute}]]" => $this->owner->getAttribute($this->parentAttribute)], |
|
300 | ['>', "{$tableName}.[[{$this->behavior->sortAttribute}]]", $this->owner->getSortablePosition()], |
|
301 | ]) |
|
302 | ->orderBy(["{$tableName}.[[{$this->behavior->sortAttribute}]]" => SORT_ASC]) |
|
303 | ->limit(1); |
|
304 | $query->multiple = false; |
|
305 | return $query; |
|
306 | } |
|
307 | ||
308 | /** |
|
309 | * @param int|null $depth |