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