1 | <?php |
||
7 | trait DynamicRelations |
||
8 | { |
||
9 | use BaseEloquentOverrides; |
||
10 | |||
11 | protected static $dynamicRelations = []; |
||
12 | |||
13 | 1 | public function getDynamicRelations() |
|
17 | |||
18 | 1 | public function hasDynamicRelation(string $relation) |
|
22 | |||
23 | 2 | public static function removeRelation(string $relationName) |
|
31 | |||
32 | 8 | public static function defineRelation($relationType, $relationName, $data, $constraints) |
|
45 | |||
46 | /** |
||
47 | * Dynamically handle calls to the class. |
||
48 | * |
||
49 | * @param string $method |
||
50 | * @param array $parameters |
||
51 | * @return mixed |
||
52 | * |
||
53 | * @throws \BadMethodCallException |
||
54 | */ |
||
55 | 7 | public function __call($method, $parameters) |
|
64 | |||
65 | /** |
||
66 | * Define a polymorphic, inverse many-to-many relationship. |
||
67 | * |
||
68 | * @param string $relationName |
||
69 | * @param string $related |
||
70 | * @param string $name |
||
71 | * @param string $table |
||
72 | * @param string $foreignPivotKey |
||
73 | * @param string $relatedPivotKey |
||
74 | * @param string $parentKey |
||
75 | * @param string $relatedKey |
||
76 | * |
||
77 | * @return \Illuminate\Database\Eloquent\Relations\MorphToMany |
||
78 | */ |
||
79 | 1 | public static function morphed_by_many($relationName, $related, $name, $table = null, $foreignPivotKey = null, |
|
85 | |||
86 | /** |
||
87 | * @param string $relationName |
||
88 | * @param string $related |
||
89 | * @param null $foreignKey |
||
90 | * @param null $localKey |
||
91 | * |
||
92 | * @return \Illuminate\Database\Eloquent\Relations\HasMany |
||
93 | */ |
||
94 | 3 | public static function has_many($relationName, $related, $foreignKey = null, $localKey = null) |
|
98 | |||
99 | /** |
||
100 | * Define a one-to-one relationship. |
||
101 | * |
||
102 | * @param string $relationName |
||
103 | * @param string $related |
||
104 | * @param string $foreignKey |
||
105 | * @param string $localKey |
||
106 | * |
||
107 | * @return \Illuminate\Database\Eloquent\Relations\HasOne |
||
108 | */ |
||
109 | 1 | public static function has_one($relationName, $related, $foreignKey = null, $localKey = null) |
|
113 | |||
114 | /** |
||
115 | * @param string $relationName |
||
116 | * @param string $related |
||
117 | * @param null $foreignKey |
||
118 | * @param null $ownerKey |
||
119 | * |
||
120 | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
||
121 | */ |
||
122 | 1 | public static function belongs_to($relationName, string $related, $foreignKey = null, $ownerKey = null) |
|
130 | |||
131 | /** |
||
132 | * Define a many-to-many relationship. |
||
133 | * |
||
134 | * @param string $relationName |
||
135 | * @param string $related |
||
136 | * @param string $table |
||
137 | * @param string $foreignPivotKey |
||
138 | * @param string $relatedPivotKey |
||
139 | * @param string $parentKey |
||
140 | * @param string $relatedKey |
||
141 | * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany |
||
142 | */ |
||
143 | 1 | public static function belongs_to_many($relationName, $related, $table = null, $foreignPivotKey = null, $relatedPivotKey = null, |
|
150 | |||
151 | /** |
||
152 | * Define a polymorphic many-to-many relationship. |
||
153 | * |
||
154 | * @param string $relationName |
||
155 | * @param string $related |
||
156 | * @param string $name |
||
157 | * @param string $table |
||
158 | * @param string $foreignPivotKey |
||
159 | * @param string $relatedPivotKey |
||
160 | * @param string $parentKey |
||
161 | * @param string $relatedKey |
||
162 | * @param bool $inverse |
||
163 | * @return \Illuminate\Database\Eloquent\Relations\MorphToMany |
||
164 | */ |
||
165 | 1 | public static function morph_to_many($relationName, $related, $name, $table = null, $foreignPivotKey = null, |
|
174 | |||
175 | /** |
||
176 | * Define a polymorphic one-to-many relationship. |
||
177 | * |
||
178 | * @param string $relationName |
||
179 | * @param string $related |
||
180 | * @param string $name |
||
181 | * @param string $type |
||
182 | * @param string $id |
||
183 | * @param string $localKey |
||
184 | * @return \Illuminate\Database\Eloquent\Relations\MorphMany |
||
185 | */ |
||
186 | 1 | public static function morph_many($relationName, $related, $name, $type = null, $id = null, $localKey = null) |
|
192 | |||
193 | /** |
||
194 | * Define a polymorphic one-to-one relationship. |
||
195 | * |
||
196 | * @param string $relationName |
||
197 | * @param string $related |
||
198 | * @param string $name |
||
199 | * @param string $type |
||
200 | * @param string $id |
||
201 | * @param string $localKey |
||
202 | * @return \Illuminate\Database\Eloquent\Relations\MorphOne |
||
203 | */ |
||
204 | public static function morph_one($relationName, $related, $name, $type = null, $id = null, $localKey = null) |
||
210 | |||
211 | /** |
||
212 | * Define a polymorphic, inverse one-to-one or many relationship. |
||
213 | * |
||
214 | * @param string $relationName |
||
215 | * @param string $type |
||
216 | * @param string $id |
||
217 | * @param string $ownerKey |
||
218 | * @return \Illuminate\Database\Eloquent\Relations\MorphTo |
||
219 | */ |
||
220 | 1 | public static function morph_to($relationName, $type = null, $id = null, $ownerKey = null) |
|
226 | |||
227 | /** |
||
228 | * Define a has-many-through relationship. |
||
229 | * |
||
230 | * @param string $relationName |
||
231 | * @param string $related |
||
232 | * @param string $through |
||
233 | * @param string|null $firstKey |
||
234 | * @param string|null $secondKey |
||
235 | * @param string|null $localKey |
||
236 | * @param string|null $secondLocalKey |
||
237 | * @return \Illuminate\Database\Eloquent\Relations\HasManyThrough |
||
238 | */ |
||
239 | 1 | public static function has_many_through($relationName, $related, $through, $firstKey = null, $secondKey = null, $localKey = null, $secondLocalKey = null) |
|
245 | |||
246 | 1 | public static function forceEagerLoading(...$relation) |
|
252 | } |
||
253 |