Commit 247da41 1 parent 5c88c2a commit 247da41 Copy full SHA for 247da41
File tree 5 files changed +49
-23
lines changed
5 files changed +49
-23
lines changed Original file line number Diff line number Diff line change 26
26
27
27
"extra" : {
28
28
"branch-alias" : {
29
- "dev-master" : " v5.0 .x-dev"
29
+ "dev-master" : " v4.1 .x-dev"
30
30
}
31
31
}
32
32
}
Original file line number Diff line number Diff line change @@ -21,6 +21,16 @@ class NestedSet
21
21
*/
22
22
const PARENT_ID = 'parent_id ' ;
23
23
24
+ /**
25
+ * Insert direction.
26
+ */
27
+ const BEFORE = 1 ;
28
+
29
+ /**
30
+ * Insert direction.
31
+ */
32
+ const AFTER = 2 ;
33
+
24
34
/**
25
35
* Add default nested set columns to the table. Also create an index.
26
36
*
Original file line number Diff line number Diff line change 5
5
use Illuminate \Database \Eloquent \Model ;
6
6
7
7
/**
8
- * @deprecated since 5.0
8
+ * @deprecated since 4.1
9
9
*/
10
10
class Node extends Model
11
11
{
12
12
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
+
13
44
}
Original file line number Diff line number Diff line change 12
12
13
13
trait NodeTrait
14
14
{
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
-
29
15
/**
30
16
* Pending operation.
31
17
*
@@ -297,20 +283,20 @@ public function descendants()
297
283
/**
298
284
* Get query for siblings of the node.
299
285
*
300
- * @param static::$after|static::$before|null $dir
286
+ * @param mixed $dir
301
287
*
302
288
* @return QueryBuilder
303
289
*/
304
290
public function siblings ($ dir = null )
305
291
{
306
292
switch ($ dir )
307
293
{
308
- case static :: $ after :
294
+ case NestedSet:: AFTER :
309
295
$ query = $ this ->nextNodes ();
310
296
311
297
break ;
312
298
313
- case static :: $ before :
299
+ case NestedSet:: BEFORE :
314
300
$ query = $ this ->prevNodes ();
315
301
316
302
break ;
@@ -335,7 +321,7 @@ public function siblings($dir = null)
335
321
*/
336
322
public function nextSiblings ()
337
323
{
338
- return $ this ->siblings (static :: $ after );
324
+ return $ this ->siblings (NestedSet:: AFTER );
339
325
}
340
326
341
327
/**
@@ -345,7 +331,7 @@ public function nextSiblings()
345
331
*/
346
332
public function prevSiblings ()
347
333
{
348
- return $ this ->siblings (static :: $ before );
334
+ return $ this ->siblings (NestedSet:: BEFORE );
349
335
}
350
336
351
337
/**
Original file line number Diff line number Diff line change 2
2
3
3
use \Illuminate \Database \Eloquent \Model ;
4
4
5
- class Category extends Model {
5
+ class Category extends \ Kalnoy \ Nestedset \Node {
6
6
7
7
use \Illuminate \Database \Eloquent \SoftDeletes;
8
- use \Kalnoy \Nestedset \NodeTrait;
9
8
10
9
protected $ fillable = array ('name ' , 'parent_id ' );
11
10
You can’t perform that action at this time.
0 commit comments