@@ -27,9 +27,9 @@ abstract class Indirect extends BelongsToMany
27
27
/**
28
28
* Create a new indirect relationship instance.
29
29
*
30
- * @param \ BeBat\PolyTree\Contracts\Node $node
31
- * @param string $foreignKey Column name that points back to this node
32
- * @param string $otherKey Column name that points to the other nodes in this relationship
30
+ * @param BeBat\PolyTree\Contracts\Node $node
31
+ * @param string $foreignKey Column name that points back to this node
32
+ * @param string $otherKey Column name that points to the other nodes in this relationship
33
33
*/
34
34
public function __construct (Node $ node , $ foreignKey , $ otherKey )
35
35
{
@@ -77,9 +77,9 @@ public function isLocked()
77
77
* Add a node to the indirect ancestry.
78
78
*
79
79
*
80
- * @param \ BeBat\PolyTree\Contracts\Node $node
81
- * @param array $attributes
82
- * @param bool $touch
80
+ * @param BeBat\PolyTree\Contracts\Node $node
81
+ * @param array $attributes
82
+ * @param bool $touch
83
83
*
84
84
* @throws \BeBat\PolyTree\Exceptions\LockedRelationship if this relationship has not been unlocked first
85
85
*/
@@ -99,7 +99,7 @@ public function attach($node, array $attributes = [], $touch = true)
99
99
* @param int|array $ids
100
100
* @param bool $touch
101
101
*
102
- * @throws \ BeBat\PolyTree\Exceptions\LockedRelationship if this relationship has not been unlocked first
102
+ * @throws BeBat\PolyTree\Exceptions\LockedRelationship if this relationship has not been unlocked first
103
103
*
104
104
* @return int Number of nodes detached
105
105
*/
@@ -115,10 +115,10 @@ public function detach($ids = [], $touch = true)
115
115
/**
116
116
* Generate a query builder object that joins the ancestor ids of $parent with the descendant ids of $child.
117
117
*
118
- * @param \ BeBat\PolyTree\Contracts\Node $parent
119
- * @param \ BeBat\PolyTree\Contracts\Node $child
118
+ * @param BeBat\PolyTree\Contracts\Node $parent
119
+ * @param BeBat\PolyTree\Contracts\Node $child
120
120
*
121
- * @return \ Illuminate\Database\Query\Builder
121
+ * @return Illuminate\Database\Query\Builder
122
122
*/
123
123
public function getQueryForJoinedNodes (Node $ parent , Node $ child )
124
124
{
@@ -151,10 +151,10 @@ public function getQueryForJoinedNodes(Node $parent, Node $child)
151
151
/**
152
152
* Generate a query that joins the id of $parent with the descendant ids of $child.
153
153
*
154
- * @param \ BeBat\PolyTree\Contracts\Node $parent
155
- * @param \ BeBat\PolyTree\Contracts\Node $child
154
+ * @param BeBat\PolyTree\Contracts\Node $parent
155
+ * @param BeBat\PolyTree\Contracts\Node $child
156
156
*
157
- * @return \ Illuminate\Database\Query\Builder
157
+ * @return Illuminate\Database\Query\Builder
158
158
*/
159
159
public function getQueryForParentDescendants (Node $ parent , Node $ child )
160
160
{
@@ -175,10 +175,10 @@ public function getQueryForParentDescendants(Node $parent, Node $child)
175
175
/**
176
176
* Generate a query that joins the id of $child with the ancestor ids of $parent.
177
177
*
178
- * @param \ BeBat\PolyTree\Contracts\Node $parent
179
- * @param \ BeBat\PolyTree\Contracts\Node $child
178
+ * @param BeBat\PolyTree\Contracts\Node $parent
179
+ * @param BeBat\PolyTree\Contracts\Node $child
180
180
*
181
- * @return \ Illuminate\Database\Query\Builder
181
+ * @return Illuminate\Database\Query\Builder
182
182
*/
183
183
public function getQueryForChildAncestors (Node $ parent , Node $ child )
184
184
{
@@ -200,10 +200,10 @@ public function getQueryForChildAncestors(Node $parent, Node $child)
200
200
* Merge the ancestors of $parent and descendants of $child.
201
201
*
202
202
*
203
- * @param \ BeBat\PolyTree\Contracts\Node $parent
204
- * @param \ BeBat\PolyTree\Contracts\Node $child
203
+ * @param BeBat\PolyTree\Contracts\Node $parent
204
+ * @param BeBat\PolyTree\Contracts\Node $child
205
205
*
206
- * @throws \ BeBat\PolyTree\Exceptions\LockedRelationship if this relationship has not been unlocked first
206
+ * @throws BeBat\PolyTree\Exceptions\LockedRelationship if this relationship has not been unlocked first
207
207
*/
208
208
public function attachAncestry (Node $ parent , Node $ child )
209
209
{
@@ -235,12 +235,14 @@ public function attachAncestry(Node $parent, Node $child)
235
235
* Appends a condition to $query for finding nodes that are either
236
236
* descendants of $parent or descendants of $parent's ancestors.
237
237
*
238
- * @param \Illuminate\Database\Query\Builder $query
239
- * @param \BeBat\PolyTree\Contracts\Node $parent
238
+ * @param Illuminate\Database\Query\Builder $query
239
+ * @param BeBat\PolyTree\Contracts\Node $parent
240
+ *
241
+ * @return Illuminate\Database\Query\Builder
240
242
*/
241
243
public function appendParentAncestorCondition (Builder $ query , Node $ parent )
242
244
{
243
- $ query ->where (function ($ parentQ ) use ($ parent ) {
245
+ return $ query ->where (function ($ parentQ ) use ($ parent ) {
244
246
$ parentQ ->orWhere ($ parent ->getAncestorKeyName (), $ parent ->getKey ());
245
247
$ parentQ ->orWhereIn ($ parent ->getAncestorKeyName (), function ($ ancestorQ ) use ($ parent ) {
246
248
$ ancestorQ ->select ($ parent ->getAncestorKeyName ())->from ($ this ->getTable ())
@@ -253,12 +255,14 @@ public function appendParentAncestorCondition(Builder $query, Node $parent)
253
255
* Appends a condition to $query for finding nodes that are either
254
256
* ancestors of $child or ancestors of $child's descendants.
255
257
*
256
- * @param \Illuminate\Database\Query\Builder $query
257
- * @param \BeBat\PolyTree\Contracts\Node $child
258
+ * @param Illuminate\Database\Query\Builder $query
259
+ * @param BeBat\PolyTree\Contracts\Node $child
260
+ *
261
+ * @return Illuminate\Database\Query\Builder
258
262
*/
259
263
public function appendChildDescendantCondition (Builder $ query , Node $ child )
260
264
{
261
- $ query ->where (function ($ childQ ) use ($ child ) {
265
+ return $ query ->where (function ($ childQ ) use ($ child ) {
262
266
$ childQ ->orWhere ($ child ->getDescendantKeyName (), $ child ->getKey ());
263
267
$ childQ ->orWhereIn ($ child ->getDescendantKeyName (), function ($ descendantQ ) use ($ child ) {
264
268
$ descendantQ ->select ($ child ->getDescendantKeyName ())->from ($ this ->getTable ())
@@ -271,46 +275,50 @@ public function appendChildDescendantCondition(Builder $query, Node $child)
271
275
* Appends a condition to $query for filtering out nodes that are either
272
276
* $parent's direct children or descendants of those children.
273
277
*
274
- * @param \Illuminate\Database\Query\Builder $query
275
- * @param \BeBat\PolyTree\Contracts\Node $parent
278
+ * @param Illuminate\Database\Query\Builder $query
279
+ * @param BeBat\PolyTree\Contracts\Node $parent
280
+ *
281
+ * @return Illuminate\Database\Query\Builder
276
282
*/
277
283
public function appendParentsChildrenNegation (Builder $ query , Node $ parent )
278
284
{
279
285
$ parentsChildrenQ = $ parent ->hasChildren ()->getBaseQuery ()->select ($ parent ->getKeyName ());
280
286
281
- $ query ->whereNotIn ($ parent ->getDescendantKeyName (), $ parentsChildrenQ );
282
- $ query ->whereNotIn ($ parent ->getDescendantKeyName (), function ($ childDescendantQ ) use ($ parent , $ parentsChildrenQ ) {
283
- $ childDescendantQ ->select ($ parent ->getDescendantKeyName ())->from ($ this ->getTable ())
284
- ->whereIn ($ parent ->getAncestorKeyName (), $ parentsChildrenQ );
285
- });
287
+ return $ query ->whereNotIn ($ parent ->getDescendantKeyName (), $ parentsChildrenQ )
288
+ ->whereNotIn ($ parent ->getDescendantKeyName (), function ($ childDescendantQ ) use ($ parent , $ parentsChildrenQ ) {
289
+ $ childDescendantQ ->select ($ parent ->getDescendantKeyName ())->from ($ this ->getTable ())
290
+ ->whereIn ($ parent ->getAncestorKeyName (), $ parentsChildrenQ );
291
+ });
286
292
}
287
293
288
294
/**
289
295
* Appends a condition to $query for filtering out nodes that are either
290
296
* $child's direct parents or ancestors of those parents.
291
297
*
292
- * @param \Illuminate\Database\Query\Builder $query
293
- * @param \BeBat\PolyTree\Contracts\Node $child
298
+ * @param Illuminate\Database\Query\Builder $query
299
+ * @param BeBat\PolyTree\Contracts\Node $child
300
+ *
301
+ * @return Illuminate\Database\Query\Builder
294
302
*/
295
303
public function appendChildsParentsNegation (Builder $ query , Node $ child )
296
304
{
297
305
$ childsParentsQ = $ child ->hasParents ()->getBaseQuery ()->select ($ child ->getKeyName ());
298
306
299
- $ query ->whereNotIn ($ child ->getAncestorKeyName (), $ childsParentsQ );
300
- $ query ->whereNotIn ($ child ->getAncestorKeyName (), function ($ parentAncestorQ ) use ($ child , $ childsParentsQ ) {
301
- $ parentAncestorQ ->select ($ child ->getAncestorKeyName ())->from ($ this ->getTable ())
302
- ->whereIn ($ child ->getDescendantKeyName (), $ childsParentsQ );
303
- });
307
+ return $ query ->whereNotIn ($ child ->getAncestorKeyName (), $ childsParentsQ )
308
+ ->whereNotIn ($ child ->getAncestorKeyName (), function ($ parentAncestorQ ) use ($ child , $ childsParentsQ ) {
309
+ $ parentAncestorQ ->select ($ child ->getAncestorKeyName ())->from ($ this ->getTable ())
310
+ ->whereIn ($ child ->getDescendantKeyName (), $ childsParentsQ );
311
+ });
304
312
}
305
313
306
314
/**
307
315
* Remove $parent's ancestors from $child, and $child's descendants from $parent.
308
316
*
309
317
*
310
- * @param \ BeBat\PolyTree\Contracts\Node $parent
311
- * @param \ BeBat\PolyTree\Contracts\Node $child
318
+ * @param BeBat\PolyTree\Contracts\Node $parent
319
+ * @param BeBat\PolyTree\Contracts\Node $child
312
320
*
313
- * @throws \ BeBat\PolyTree\Exceptions\LockedRelationship if this relationship has not been unlocked first
321
+ * @throws BeBat\PolyTree\Exceptions\LockedRelationship if this relationship has not been unlocked first
314
322
*
315
323
* @return int Number of rows deleted
316
324
*/
0 commit comments