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