1 | <?php namespace Arcanedev\LaravelNestedSet\Eloquent; |
||
20 | class DescendantsRelation extends Relation |
||
21 | { |
||
22 | /* ------------------------------------------------------------------------------------------------ |
||
23 | | Properties |
||
24 | | ------------------------------------------------------------------------------------------------ |
||
25 | */ |
||
26 | /** |
||
27 | * The Eloquent query builder instance. |
||
28 | * |
||
29 | * @var \Arcanedev\LaravelNestedSet\Eloquent\QueryBuilder |
||
30 | */ |
||
31 | protected $query; |
||
32 | |||
33 | /** |
||
34 | * The parent model instance. |
||
35 | * |
||
36 | * @var \Arcanedev\LaravelNestedSet\NodeTrait |
||
37 | */ |
||
38 | protected $parent; |
||
39 | |||
40 | /* ------------------------------------------------------------------------------------------------ |
||
41 | | Constructor |
||
42 | | ------------------------------------------------------------------------------------------------ |
||
43 | */ |
||
44 | /** |
||
45 | * DescendantsRelation constructor. |
||
46 | * |
||
47 | * @param \Arcanedev\LaravelNestedSet\Eloquent\QueryBuilder $builder |
||
48 | * @param \Illuminate\Database\Eloquent\Model|NodeTrait $model |
||
49 | */ |
||
50 | 48 | public function __construct(QueryBuilder $builder, Model $model) |
|
60 | |||
61 | /** |
||
62 | * Add the constraints for a relationship query. |
||
63 | * |
||
64 | * @param \Illuminate\Database\Eloquent\Builder $query |
||
65 | * @param \Illuminate\Database\Eloquent\Builder $parent |
||
66 | * @param array|mixed $columns |
||
67 | * |
||
68 | * @return \Illuminate\Database\Eloquent\Builder |
||
69 | */ |
||
70 | 4 | public function getRelationQuery( |
|
89 | |||
90 | /** |
||
91 | * Get a relationship join table hash. |
||
92 | * |
||
93 | * @return string |
||
94 | */ |
||
95 | 4 | public function getRelationCountHash() |
|
99 | |||
100 | /** |
||
101 | * Set the base constraints on the relation query. |
||
102 | */ |
||
103 | 48 | public function addConstraints() |
|
111 | |||
112 | /** |
||
113 | * Set the constraints for an eager load of the relation. |
||
114 | * |
||
115 | * @param array $models |
||
116 | */ |
||
117 | public function addEagerConstraints(array $models) |
||
128 | |||
129 | /** |
||
130 | * Initialize the relation on a set of models. |
||
131 | * |
||
132 | * @param array $models |
||
133 | * @param string $relation |
||
134 | * |
||
135 | * @return array |
||
136 | */ |
||
137 | 4 | public function initRelation(array $models, $relation) |
|
141 | |||
142 | /** |
||
143 | * Match the eagerly loaded results to their parents. |
||
144 | * |
||
145 | * @param array $models |
||
146 | * @param \Illuminate\Database\Eloquent\Collection $results |
||
147 | * @param string $relation |
||
148 | * |
||
149 | * @return array |
||
150 | */ |
||
151 | 4 | public function match(array $models, EloquentCollection $results, $relation) |
|
163 | |||
164 | /** |
||
165 | * Get the results of the relationship. |
||
166 | * |
||
167 | * @return mixed |
||
168 | */ |
||
169 | 4 | public function getResults() |
|
173 | |||
174 | /** |
||
175 | * @param \Illuminate\Database\Eloquent\Model $model |
||
176 | * @param \Illuminate\Database\Eloquent\Collection $results |
||
177 | * |
||
178 | * @return \Arcanedev\LaravelNestedSet\Eloquent\Collection |
||
179 | */ |
||
180 | 4 | protected function getDescendantsForModel(Model $model, EloquentCollection $results) |
|
192 | } |
||
193 |
If you implement
__call
and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.This is often the case, when
__call
is implemented by a parent class and only the child class knows which methods exist: