Created
October 5, 2013 05:58
-
-
Save franzose/6837241 to your computer and use it in GitHub Desktop.
in app/routes.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// everything's creating fine. Positions and closure table, all's fine. | |
$Test = Test::create(array()); | |
$child1 = $Test->appendChild(Test::make(), 0, true); | |
$child2 = $Test->appendChild(Test::make(), 1, true); | |
$child3 = $Test->appendChild(Test::make(), 2, true); | |
$child4 = $Test->appendChild(Test::make(), 3, true); | |
// this returns ids of $Test, $child1, $child2 and $child3... | |
dd($child4->prevSiblings()->lists('id')); | |
// returns id | |
dd($child4->getKey()); | |
// then i do this | |
/** | |
* Build a part of the siblings query. | |
* This part defines a sibling regardless of direction (prev or next) and position. | |
* | |
* @param array $columns | |
* @return \Illuminate\Database\Eloquent\Builder | |
*/ | |
protected function buildSiblingsSubquery(array $columns = array('*')) | |
{ | |
$dk = $this->getQualifiedDescendantKeyName(); | |
$dpk = $this->getQualifiedDepthKeyName(); | |
dd($this); //note this | |
return $this->select($this->getSelectedColumns($columns)) | |
->join($this->getClosure(), $dk, '=', $this->getQualifiedKeyName()) | |
->where($dk, '<>', $this->getKey()) | |
->where($dpk, '=', $this->getDepth()); | |
} | |
// that dd returns me this | |
object(Test)[123] | |
protected 'table' => string 'tests' (length=5) | |
public 'timestamps' => boolean false | |
protected 'closure' => string 'tests_closure' (length=13) | |
protected 'softDelete' => boolean true | |
protected 'connection' => null | |
protected 'primaryKey' => string 'id' (length=2) | |
protected 'perPage' => int 15 | |
public 'incrementing' => boolean true | |
protected 'attributes' => | |
array (size=0) | |
empty | |
protected 'original' => | |
array (size=0) | |
empty | |
protected 'relations' => | |
array (size=0) | |
empty | |
protected 'hidden' => | |
array (size=1) | |
'depth' => int 0 | |
protected 'visible' => | |
array (size=0) | |
empty | |
protected 'appends' => | |
array (size=0) | |
empty | |
protected 'fillable' => | |
array (size=1) | |
0 => string 'position' (length=8) | |
protected 'guarded' => | |
array (size=1) | |
0 => string '*' (length=1) | |
protected 'dates' => | |
array (size=0) | |
empty | |
protected 'touches' => | |
array (size=0) | |
empty | |
protected 'with' => | |
array (size=0) | |
empty | |
public 'exists' => boolean false | |
// fucking what?! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment