File tree Expand file tree Collapse file tree 5 files changed +49
-23
lines changed Expand file tree Collapse file tree 5 files changed +49
-23
lines changed Original file line number Diff line number Diff line change 2626
2727 "extra" : {
2828 "branch-alias" : {
29- "dev-master" : " v5.0 .x-dev"
29+ "dev-master" : " v4.1 .x-dev"
3030 }
3131 }
3232}
Original file line number Diff line number Diff line change @@ -21,6 +21,16 @@ class NestedSet
2121 */
2222 const PARENT_ID = 'parent_id ' ;
2323
24+ /**
25+ * Insert direction.
26+ */
27+ const BEFORE = 1 ;
28+
29+ /**
30+ * Insert direction.
31+ */
32+ const AFTER = 2 ;
33+
2434 /**
2535 * Add default nested set columns to the table. Also create an index.
2636 *
Original file line number Diff line number Diff line change 55use Illuminate \Database \Eloquent \Model ;
66
77/**
8- * @deprecated since 5.0
8+ * @deprecated since 4.1
99 */
1010class Node extends Model
1111{
1212 use NodeTrait;
13+
14+ const LFT = NestedSet::LFT ;
15+
16+ const RGT = NestedSet::RGT ;
17+
18+ const PARENT_ID = NestedSet::PARENT_ID ;
19+
20+ /**
21+ * @return string
22+ */
23+ public function getParentIdName ()
24+ {
25+ return static ::PARENT_ID ;
26+ }
27+
28+ /**
29+ * @return string
30+ */
31+ public function getLftName ()
32+ {
33+ return static ::LFT ;
34+ }
35+
36+ /**
37+ * @return string
38+ */
39+ public function getRgtName ()
40+ {
41+ return static ::RGT ;
42+ }
43+
1344}
Original file line number Diff line number Diff line change 1212
1313trait NodeTrait
1414{
15- /**
16- * Insert direction.
17- *
18- * @var string
19- */
20- public static $ before = 'before ' ;
21-
22- /**
23- * Insert direction.
24- *
25- * @var string
26- */
27- public static $ after = 'after ' ;
28-
2915 /**
3016 * Pending operation.
3117 *
@@ -297,20 +283,20 @@ public function descendants()
297283 /**
298284 * Get query for siblings of the node.
299285 *
300- * @param static::$after|static::$before|null $dir
286+ * @param mixed $dir
301287 *
302288 * @return QueryBuilder
303289 */
304290 public function siblings ($ dir = null )
305291 {
306292 switch ($ dir )
307293 {
308- case static :: $ after :
294+ case NestedSet:: AFTER :
309295 $ query = $ this ->nextNodes ();
310296
311297 break ;
312298
313- case static :: $ before :
299+ case NestedSet:: BEFORE :
314300 $ query = $ this ->prevNodes ();
315301
316302 break ;
@@ -335,7 +321,7 @@ public function siblings($dir = null)
335321 */
336322 public function nextSiblings ()
337323 {
338- return $ this ->siblings (static :: $ after );
324+ return $ this ->siblings (NestedSet:: AFTER );
339325 }
340326
341327 /**
@@ -345,7 +331,7 @@ public function nextSiblings()
345331 */
346332 public function prevSiblings ()
347333 {
348- return $ this ->siblings (static :: $ before );
334+ return $ this ->siblings (NestedSet:: BEFORE );
349335 }
350336
351337 /**
Original file line number Diff line number Diff line change 22
33use \Illuminate \Database \Eloquent \Model ;
44
5- class Category extends Model {
5+ class Category extends \ Kalnoy \ Nestedset \Node {
66
77 use \Illuminate \Database \Eloquent \SoftDeletes;
8- use \Kalnoy \Nestedset \NodeTrait;
98
109 protected $ fillable = array ('name ' , 'parent_id ' );
1110
You can’t perform that action at this time.
0 commit comments