|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Modules\Entitizer\Utils\Entity { |
|
4
|
|
|
|
|
5
|
|
|
use Modules\Entitizer; |
|
6
|
|
|
|
|
7
|
|
|
trait View { |
|
8
|
|
|
|
|
9
|
|
|
protected $definition = null, $error = false, $modifiable = false, $data = []; |
|
10
|
|
|
|
|
11
|
|
|
# Get items |
|
12
|
|
|
|
|
13
|
|
|
public function items(array $config = [], array $order_by = [], int $index = 0, int $display = 0) { |
|
14
|
|
|
|
|
15
|
|
|
return Entitizer::listview(static::$table)->items($config, $order_by, $index, $display); |
|
16
|
|
|
} |
|
17
|
|
|
|
|
18
|
|
|
# Get items count |
|
19
|
|
|
|
|
20
|
|
|
public function itemsCount(array $config = []) { |
|
21
|
|
|
|
|
22
|
|
|
return Entitizer::listview(static::$table)->itemsCount($config); |
|
23
|
|
|
} |
|
24
|
|
|
|
|
25
|
|
|
# Get children |
|
26
|
|
|
|
|
27
|
|
|
public function children(array $config = [], array $order_by = [], int $index = 0, int $display = 0) { |
|
28
|
|
|
|
|
29
|
|
|
return Entitizer::listview(static::$table)->children($this->id, $config, $order_by, $index, $display); |
|
|
|
|
|
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
# Get children count |
|
33
|
|
|
|
|
34
|
|
|
public function childrenCount(array $config = []) { |
|
35
|
|
|
|
|
36
|
|
|
return Entitizer::listview(static::$table)->childrenCount($this->id, $config); |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
# Get subtree |
|
40
|
|
|
|
|
41
|
|
|
public function subtree(array $config = [], array $order_by = []) { |
|
42
|
|
|
|
|
43
|
|
|
return Entitizer::treeview(static::$table)->subtree($this->id, $config, $order_by); |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
# Get subtree count |
|
47
|
|
|
|
|
48
|
|
|
public function subtreeCount() { |
|
49
|
|
|
|
|
50
|
|
|
return Entitizer::treeview(static::$table)->subtreeCount($this->id); |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
# Get subtree depth |
|
54
|
|
|
|
|
55
|
|
|
public function subtreeDepth() { |
|
56
|
|
|
|
|
57
|
|
|
return Entitizer::treeview(static::$table)->subtreeDepth($this->id); |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
# Get path |
|
61
|
|
|
|
|
62
|
|
|
public function path() { |
|
63
|
|
|
|
|
64
|
|
|
return Entitizer::treeview(static::$table)->path($this->id); |
|
65
|
|
|
} |
|
66
|
|
|
} |
|
67
|
|
|
} |
|
68
|
|
|
|
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: