1 | <?php |
||
7 | trait DynamicRelations |
||
8 | { |
||
9 | use BaseEloquentOverrides; |
||
10 | |||
11 | protected static $dynamicRelations = []; |
||
12 | |||
13 | 7 | public static function defineRelation($relationType, $relationName, $data, $constraints) |
|
26 | |||
27 | /** |
||
28 | * Dynamically handle calls to the class. |
||
29 | * |
||
30 | * @param string $method |
||
31 | * @param array $parameters |
||
32 | * @return mixed |
||
33 | * |
||
34 | * @throws \BadMethodCallException |
||
35 | */ |
||
36 | 7 | public function __call($method, $parameters) |
|
45 | |||
46 | 1 | public static function morphed_by_many($relationName, $related, $name, $table = null, $foreignPivotKey = null, |
|
52 | |||
53 | /** |
||
54 | * @param string $related |
||
55 | * @param $relationName |
||
56 | * @param null $foreignKey |
||
57 | * @param null $localKey |
||
58 | * |
||
59 | * @return \Illuminate\Database\Eloquent\Relations\HasMany |
||
60 | */ |
||
61 | 2 | public static function has_many($relationName, string $related, $foreignKey = null, $localKey = null) |
|
65 | |||
66 | /** |
||
67 | * Define a one-to-one relationship. |
||
68 | * |
||
69 | * @param string $related |
||
70 | * @param string $foreignKey |
||
71 | * @param string $localKey |
||
72 | * |
||
73 | * @return \Illuminate\Database\Eloquent\Relations\HasOne |
||
74 | */ |
||
75 | 1 | public static function has_one($relationName, $related, $foreignKey = null, $localKey = null) |
|
79 | |||
80 | /** |
||
81 | * @param string $related |
||
82 | * @param $relationName |
||
83 | * @param null $foreignKey |
||
84 | * @param null $ownerKey |
||
85 | * |
||
86 | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
||
87 | */ |
||
88 | 1 | public static function belongs_to($relationName, string $related, $foreignKey = null, $ownerKey = null) |
|
96 | |||
97 | /** |
||
98 | * Define a many-to-many relationship. |
||
99 | * |
||
100 | * @param string $relationName |
||
101 | * @param string $related |
||
102 | * @param string $table |
||
103 | * @param string $foreignPivotKey |
||
104 | * @param string $relatedPivotKey |
||
105 | * @param string $parentKey |
||
106 | * @param string $relatedKey |
||
107 | * |
||
108 | * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany |
||
109 | */ |
||
110 | 1 | public static function belongs_to_many($relationName, $related, $table = null, $foreignPivotKey = null, $relatedPivotKey = null, |
|
117 | |||
118 | /** |
||
119 | * Define a polymorphic many-to-many relationship. |
||
120 | * |
||
121 | * @param string $relationName |
||
122 | * @param string $related |
||
123 | * @param string $name |
||
124 | * @param string $table |
||
125 | * @param string $foreignPivotKey |
||
126 | * @param string $relatedPivotKey |
||
127 | * @param string $parentKey |
||
128 | * @param string $relatedKey |
||
129 | * @param bool $inverse |
||
130 | * |
||
131 | * @return \Illuminate\Database\Eloquent\Relations\MorphToMany |
||
132 | */ |
||
133 | 1 | public static function morph_to_many($relationName, $related, $name, $table = null, $foreignPivotKey = null, |
|
142 | |||
143 | /** |
||
144 | * Define a polymorphic one-to-many relationship. |
||
145 | * |
||
146 | * @param string $relationName |
||
147 | * @param string $related |
||
148 | * @param string $name |
||
149 | * @param string $type |
||
150 | * @param string $id |
||
151 | * @param string $localKey |
||
152 | * |
||
153 | * @return \Illuminate\Database\Eloquent\Relations\MorphMany |
||
154 | */ |
||
155 | 1 | public static function morph_many($relationName, $related, $name, $type = null, $id = null, $localKey = null) |
|
161 | |||
162 | /** |
||
163 | * Define a polymorphic one-to-one relationship. |
||
164 | * |
||
165 | * @param string $related |
||
166 | * @param string $name |
||
167 | * @param string $type |
||
168 | * @param string $id |
||
169 | * @param string $localKey |
||
170 | * @return \Illuminate\Database\Eloquent\Relations\MorphOne |
||
171 | */ |
||
172 | public static function morph_one($relationName, $related, $name, $type = null, $id = null, $localKey = null) |
||
178 | |||
179 | /** |
||
180 | * Define a polymorphic, inverse one-to-one or many relationship. |
||
181 | * |
||
182 | * @param string $relationName |
||
183 | * @param string $type |
||
184 | * @param string $id |
||
185 | * @param string $ownerKey |
||
186 | * @return \Illuminate\Database\Eloquent\Relations\MorphTo |
||
187 | */ |
||
188 | 1 | public static function morph_to($relationName, $type = null, $id = null, $ownerKey = null) |
|
194 | |||
195 | /** |
||
196 | * Define a has-many-through relationship. |
||
197 | * |
||
198 | * @param string $relationName |
||
199 | * @param string $related |
||
200 | * @param string $through |
||
201 | * @param string|null $firstKey |
||
202 | * @param string|null $secondKey |
||
203 | * @param string|null $localKey |
||
204 | * @param string|null $secondLocalKey |
||
205 | * |
||
206 | * @return \Illuminate\Database\Eloquent\Relations\HasManyThrough |
||
207 | */ |
||
208 | 1 | public static function has_many_through($relationName, $related, $through, $firstKey = null, $secondKey = null, $localKey = null, $secondLocalKey = null) |
|
214 | |||
215 | 1 | public static function forceEagerLoading(...$relation) |
|
221 | } |
||
222 |