1 | <?php |
||
7 | trait DynamicRelations |
||
8 | { |
||
9 | use BaseEloquentOverrides; |
||
10 | |||
11 | protected static $dynamicRelations = []; |
||
12 | |||
13 | public function getDynamicRelations() |
||
17 | |||
18 | public function hasDynamicRelation(string $relation) |
||
22 | |||
23 | 7 | public static function defineRelation($relationType, $relationName, $data, $constraints) |
|
36 | |||
37 | /** |
||
38 | * Dynamically handle calls to the class. |
||
39 | * |
||
40 | * @param string $method |
||
41 | * @param array $parameters |
||
42 | * @return mixed |
||
43 | * |
||
44 | * @throws \BadMethodCallException |
||
45 | */ |
||
46 | 7 | public function __call($method, $parameters) |
|
55 | |||
56 | /** |
||
57 | * Define a polymorphic, inverse many-to-many relationship. |
||
58 | * |
||
59 | * @param string $relationName |
||
60 | * @param string $related |
||
61 | * @param string $name |
||
62 | * @param string $table |
||
63 | * @param string $foreignPivotKey |
||
64 | * @param string $relatedPivotKey |
||
65 | * @param string $parentKey |
||
66 | * @param string $relatedKey |
||
67 | * |
||
68 | * @return \Illuminate\Database\Eloquent\Relations\MorphToMany |
||
69 | */ |
||
70 | 1 | public static function morphed_by_many($relationName, $related, $name, $table = null, $foreignPivotKey = null, |
|
76 | |||
77 | /** |
||
78 | * @param string $relationName |
||
79 | * @param string $related |
||
80 | * @param null $foreignKey |
||
81 | * @param null $localKey |
||
82 | * |
||
83 | * @return \Illuminate\Database\Eloquent\Relations\HasMany |
||
84 | */ |
||
85 | 2 | public static function has_many($relationName, $related, $foreignKey = null, $localKey = null) |
|
89 | |||
90 | /** |
||
91 | * Define a one-to-one relationship. |
||
92 | * |
||
93 | * @param string $relationName |
||
94 | * @param string $related |
||
95 | * @param string $foreignKey |
||
96 | * @param string $localKey |
||
97 | * |
||
98 | * @return \Illuminate\Database\Eloquent\Relations\HasOne |
||
99 | */ |
||
100 | 1 | public static function has_one($relationName, $related, $foreignKey = null, $localKey = null) |
|
104 | |||
105 | /** |
||
106 | * @param string $relationName |
||
107 | * @param string $related |
||
108 | * @param null $foreignKey |
||
109 | * @param null $ownerKey |
||
110 | * |
||
111 | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
||
112 | */ |
||
113 | 1 | public static function belongs_to($relationName, string $related, $foreignKey = null, $ownerKey = null) |
|
121 | |||
122 | /** |
||
123 | * Define a many-to-many relationship. |
||
124 | * |
||
125 | * @param string $relationName |
||
126 | * @param string $related |
||
127 | * @param string $table |
||
128 | * @param string $foreignPivotKey |
||
129 | * @param string $relatedPivotKey |
||
130 | * @param string $parentKey |
||
131 | * @param string $relatedKey |
||
132 | * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany |
||
133 | */ |
||
134 | 1 | public static function belongs_to_many($relationName, $related, $table = null, $foreignPivotKey = null, $relatedPivotKey = null, |
|
141 | |||
142 | /** |
||
143 | * Define a polymorphic many-to-many relationship. |
||
144 | * |
||
145 | * @param string $relationName |
||
146 | * @param string $related |
||
147 | * @param string $name |
||
148 | * @param string $table |
||
149 | * @param string $foreignPivotKey |
||
150 | * @param string $relatedPivotKey |
||
151 | * @param string $parentKey |
||
152 | * @param string $relatedKey |
||
153 | * @param bool $inverse |
||
154 | * @return \Illuminate\Database\Eloquent\Relations\MorphToMany |
||
155 | */ |
||
156 | 1 | public static function morph_to_many($relationName, $related, $name, $table = null, $foreignPivotKey = null, |
|
165 | |||
166 | /** |
||
167 | * Define a polymorphic one-to-many relationship. |
||
168 | * |
||
169 | * @param string $relationName |
||
170 | * @param string $related |
||
171 | * @param string $name |
||
172 | * @param string $type |
||
173 | * @param string $id |
||
174 | * @param string $localKey |
||
175 | * @return \Illuminate\Database\Eloquent\Relations\MorphMany |
||
176 | */ |
||
177 | 1 | public static function morph_many($relationName, $related, $name, $type = null, $id = null, $localKey = null) |
|
183 | |||
184 | /** |
||
185 | * Define a polymorphic one-to-one relationship. |
||
186 | * |
||
187 | * @param string $relationName |
||
188 | * @param string $related |
||
189 | * @param string $name |
||
190 | * @param string $type |
||
191 | * @param string $id |
||
192 | * @param string $localKey |
||
193 | * @return \Illuminate\Database\Eloquent\Relations\MorphOne |
||
194 | */ |
||
195 | public static function morph_one($relationName, $related, $name, $type = null, $id = null, $localKey = null) |
||
201 | |||
202 | /** |
||
203 | * Define a polymorphic, inverse one-to-one or many relationship. |
||
204 | * |
||
205 | * @param string $relationName |
||
206 | * @param string $type |
||
207 | * @param string $id |
||
208 | * @param string $ownerKey |
||
209 | * @return \Illuminate\Database\Eloquent\Relations\MorphTo |
||
210 | */ |
||
211 | 1 | public static function morph_to($relationName, $type = null, $id = null, $ownerKey = null) |
|
217 | |||
218 | /** |
||
219 | * Define a has-many-through relationship. |
||
220 | * |
||
221 | * @param string $relationName |
||
222 | * @param string $related |
||
223 | * @param string $through |
||
224 | * @param string|null $firstKey |
||
225 | * @param string|null $secondKey |
||
226 | * @param string|null $localKey |
||
227 | * @param string|null $secondLocalKey |
||
228 | * @return \Illuminate\Database\Eloquent\Relations\HasManyThrough |
||
229 | */ |
||
230 | 1 | public static function has_many_through($relationName, $related, $through, $firstKey = null, $secondKey = null, $localKey = null, $secondLocalKey = null) |
|
236 | |||
237 | 1 | public static function forceEagerLoading(...$relation) |
|
243 | } |
||
244 |