4
4
5
5
use Illuminate \Database \Eloquent \Builder ;
6
6
use Illuminate \Database \Eloquent \Concerns \HasRelationships ;
7
+ use Illuminate \Database \Eloquent \Model ;
7
8
use Illuminate \Database \Eloquent \Relations \BelongsTo ;
8
9
use Illuminate \Database \Eloquent \Relations \BelongsToMany ;
9
10
use Illuminate \Database \Eloquent \Relations \HasMany ;
14
15
use Illuminate \Database \Eloquent \Relations \MorphOne ;
15
16
use Illuminate \Database \Eloquent \Relations \MorphTo ;
16
17
use Illuminate \Database \Eloquent \Relations \MorphToMany ;
17
- use MacropaySolutions \LaravelCrudWizard \Models \BaseModel as Model ;
18
18
19
19
/**
20
20
* @see HasRelationships
@@ -24,7 +24,10 @@ trait HasCleverRelationships
24
24
{
25
25
public ?string $ nowEagerLoadingRelationNameWithNoConstraints = null ;
26
26
27
- protected function newHasOne (Builder $ query , Model $ parent , string $ foreignKey , string $ localKey ): HasOne
27
+ /**
28
+ * @inheritDoc
29
+ */
30
+ protected function newHasOne (Builder $ query , Model $ parent , $ foreignKey , $ localKey ): HasOne
28
31
{
29
32
return new class ($ query , $ parent , $ foreignKey , $ localKey ) extends HasOne {
30
33
use RelationCleverTrait;
@@ -38,14 +41,17 @@ public function __construct(Builder $query, Model $parent, string $foreignKey, s
38
41
};
39
42
}
40
43
44
+ /**
45
+ * @inheritDoc
46
+ */
41
47
protected function newHasOneThrough (
42
48
Builder $ query ,
43
49
Model $ farParent ,
44
50
Model $ throughParent ,
45
- string $ firstKey ,
46
- string $ secondKey ,
47
- string $ localKey ,
48
- string $ secondLocalKey
51
+ $ firstKey ,
52
+ $ secondKey ,
53
+ $ localKey ,
54
+ $ secondLocalKey
49
55
): HasOneThrough {
50
56
return new class (
51
57
$ query ,
@@ -82,7 +88,10 @@ public function __construct(
82
88
};
83
89
}
84
90
85
- protected function newMorphOne (Builder $ query , Model $ parent , string $ type , string $ id , string $ localKey ): MorphOne
91
+ /**
92
+ * @inheritDoc
93
+ */
94
+ protected function newMorphOne (Builder $ query , Model $ parent , $ type , $ id , $ localKey ): MorphOne
86
95
{
87
96
return new class ($ query , $ parent , $ type , $ id , $ localKey ) extends MorphOne {
88
97
use RelationCleverTrait;
@@ -96,12 +105,15 @@ public function __construct(Builder $query, Model $parent, string $type, string
96
105
};
97
106
}
98
107
108
+ /**
109
+ * @inheritDoc
110
+ */
99
111
protected function newBelongsTo (
100
112
Builder $ query ,
101
113
Model $ child ,
102
- string $ foreignKey ,
103
- string $ ownerKey ,
104
- string $ relation
114
+ $ foreignKey ,
115
+ $ ownerKey ,
116
+ $ relation
105
117
): BelongsTo {
106
118
return new class ($ query , $ child , $ foreignKey , $ ownerKey , $ relation ) extends BelongsTo {
107
119
use RelationCleverTrait;
@@ -120,13 +132,16 @@ public function __construct(
120
132
};
121
133
}
122
134
135
+ /**
136
+ * @inheritDoc
137
+ */
123
138
protected function newMorphTo (
124
139
Builder $ query ,
125
140
Model $ parent ,
126
- string $ foreignKey ,
127
- string $ ownerKey ,
128
- string $ type ,
129
- string $ relation
141
+ $ foreignKey ,
142
+ $ ownerKey ,
143
+ $ type ,
144
+ $ relation
130
145
): MorphTo {
131
146
return new class ($ query , $ parent , $ foreignKey , $ ownerKey , $ type , $ relation ) extends MorphTo {
132
147
use RelationCleverTrait;
@@ -146,7 +161,10 @@ public function __construct(
146
161
};
147
162
}
148
163
149
- protected function newHasMany (Builder $ query , Model $ parent , string $ foreignKey , string $ localKey ): HasMany
164
+ /**
165
+ * @inheritDoc
166
+ */
167
+ protected function newHasMany (Builder $ query , Model $ parent , $ foreignKey , $ localKey ): HasMany
150
168
{
151
169
return new class ($ query , $ parent , $ foreignKey , $ localKey ) extends HasMany {
152
170
use RelationCleverTrait;
@@ -160,14 +178,17 @@ public function __construct(Builder $query, Model $parent, string $foreignKey, s
160
178
};
161
179
}
162
180
181
+ /**
182
+ * @inheritDoc
183
+ */
163
184
protected function newHasManyThrough (
164
185
Builder $ query ,
165
186
Model $ farParent ,
166
187
Model $ throughParent ,
167
- string $ firstKey ,
168
- string $ secondKey ,
169
- string $ localKey ,
170
- string $ secondLocalKey
188
+ $ firstKey ,
189
+ $ secondKey ,
190
+ $ localKey ,
191
+ $ secondLocalKey
171
192
): HasManyThrough {
172
193
return new class ($ query , $ farParent , $ throughParent , $ firstKey , $ secondKey , $ localKey , $ secondLocalKey ) extends
173
194
HasManyThrough {
@@ -197,6 +218,9 @@ public function __construct(
197
218
};
198
219
}
199
220
221
+ /**
222
+ * @inheritDoc
223
+ */
200
224
protected function newMorphMany (Builder $ query , Model $ parent , $ type , $ id , $ localKey ): MorphMany
201
225
{
202
226
return new class ($ query , $ parent , $ type , $ id , $ localKey ) extends MorphMany {
@@ -211,15 +235,18 @@ public function __construct(Builder $query, Model $parent, string $type, string
211
235
};
212
236
}
213
237
238
+ /**
239
+ * @inheritDoc
240
+ */
214
241
protected function newBelongsToMany (
215
242
Builder $ query ,
216
243
Model $ parent ,
217
- string $ table ,
218
- string $ foreignPivotKey ,
219
- string $ relatedPivotKey ,
220
- string $ parentKey ,
221
- string $ relatedKey ,
222
- ? string $ relationName = null
244
+ $ table ,
245
+ $ foreignPivotKey ,
246
+ $ relatedPivotKey ,
247
+ $ parentKey ,
248
+ $ relatedKey ,
249
+ $ relationName = null
223
250
): BelongsToMany {
224
251
return new class ($ query , $ parent , $ table , $ foreignPivotKey , $ relatedPivotKey , $ parentKey , $ relatedKey , $ relationName ) extends
225
252
BelongsToMany {
@@ -251,20 +278,32 @@ public function __construct(
251
278
};
252
279
}
253
280
281
+ /**
282
+ * @inheritDoc
283
+ */
254
284
protected function newMorphToMany (
255
285
Builder $ query ,
256
286
Model $ parent ,
257
- string $ name ,
258
- string $ table ,
259
- string $ foreignPivotKey ,
260
- string $ relatedPivotKey ,
261
- string $ parentKey ,
262
- string $ relatedKey ,
263
- ? string $ relationName = null ,
264
- bool $ inverse = false
287
+ $ name ,
288
+ $ table ,
289
+ $ foreignPivotKey ,
290
+ $ relatedPivotKey ,
291
+ $ parentKey ,
292
+ $ relatedKey ,
293
+ $ relationName = null ,
294
+ $ inverse = false
265
295
): MorphToMany {
266
- return new class ($ query , $ parent , $ name , $ table , $ foreignPivotKey , $ relatedPivotKey , $ parentKey , $ relatedKey ,
267
- $ relationName , $ inverse
296
+ return new class (
297
+ $ query ,
298
+ $ parent ,
299
+ $ name ,
300
+ $ table ,
301
+ $ foreignPivotKey ,
302
+ $ relatedPivotKey ,
303
+ $ parentKey ,
304
+ $ relatedKey ,
305
+ $ relationName ,
306
+ $ inverse
268
307
) extends MorphToMany {
269
308
use RelationCleverTrait;
270
309
0 commit comments