1 | <?php |
||
7 | trait DynamicRelations |
||
8 | { |
||
9 | use BaseEloquentOverrides; |
||
10 | |||
11 | protected static $dynamicRelations = []; |
||
12 | |||
13 | 6 | public static function defineRelation($name, $macro) |
|
17 | |||
18 | /** |
||
19 | * Dynamically handle calls to the class. |
||
20 | * |
||
21 | * @param string $method |
||
22 | * @param array $parameters |
||
23 | * @return mixed |
||
24 | * |
||
25 | * @throws \BadMethodCallException |
||
26 | */ |
||
27 | 6 | public function __call($method, $parameters) |
|
36 | |||
37 | 1 | public static function morphed_by_many($relationName, $related, $name, $table = null, $foreignPivotKey = null, |
|
43 | |||
44 | /** |
||
45 | * @param string $related |
||
46 | * @param $relationName |
||
47 | * @param null $foreignKey |
||
48 | * @param null $localKey |
||
49 | * |
||
50 | * @return \Illuminate\Database\Eloquent\Relations\HasMany |
||
51 | */ |
||
52 | 2 | public static function has_many($relationName = null, string $related, $foreignKey = null, $localKey = null) |
|
56 | |||
57 | 1 | public static function has_one($relationName = null, $related, $foreignKey = null, $localKey = null) |
|
61 | |||
62 | /** |
||
63 | * @param string $related |
||
64 | * @param $relationName |
||
65 | * @param null $foreignKey |
||
66 | * @param null $ownerKey |
||
67 | * |
||
68 | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
||
69 | */ |
||
70 | 1 | public static function belongs_to($relationName = null, string $related, $foreignKey = null, $ownerKey = null) |
|
78 | |||
79 | 1 | public static function belongs_to_many($relationName, $related, $table = null, $foreignPivotKey = null, $relatedPivotKey = null, |
|
86 | |||
87 | /** |
||
88 | * Define a polymorphic many-to-many relationship. |
||
89 | * |
||
90 | * @param string $relationName |
||
91 | * @param string $related |
||
92 | * @param string $name |
||
93 | * @param string $table |
||
94 | * @param string $foreignPivotKey |
||
95 | * @param string $relatedPivotKey |
||
96 | * @param string $parentKey |
||
97 | * @param string $relatedKey |
||
98 | * @param bool $inverse |
||
99 | * |
||
100 | * @return \Illuminate\Database\Eloquent\Relations\MorphToMany |
||
101 | */ |
||
102 | 1 | public static function morph_to_many($relationName, $related, $name, $table = null, $foreignPivotKey = null, |
|
111 | |||
112 | /** |
||
113 | * Define a polymorphic one-to-many relationship. |
||
114 | * |
||
115 | * @param string $relationName |
||
116 | * @param string $related |
||
117 | * @param string $name |
||
118 | * @param string $type |
||
119 | * @param string $id |
||
120 | * @param string $localKey |
||
121 | * |
||
122 | * @return \Illuminate\Database\Eloquent\Relations\MorphMany |
||
123 | */ |
||
124 | 1 | public static function morph_many($relationName, $related, $name, $type = null, $id = null, $localKey = null) |
|
130 | |||
131 | public static function morph_one($relationName, $related, $name, $type = null, $id = null, $localKey = null) |
||
136 | |||
137 | public static function morph_to($relationName, $type = null, $id = null, $ownerKey = null) |
||
143 | |||
144 | /** |
||
145 | * Define a has-many-through relationship. |
||
146 | * |
||
147 | * @param string $relationName |
||
148 | * @param string $related |
||
149 | * @param string $through |
||
150 | * @param string|null $firstKey |
||
151 | * @param string|null $secondKey |
||
152 | * @param string|null $localKey |
||
153 | * @param string|null $secondLocalKey |
||
154 | * |
||
155 | * @return \Imanghafoori\Relativity\AbstractRelation |
||
156 | */ |
||
157 | public static function has_many_through($relationName, $related, $through, $firstKey = null, $secondKey = null, $localKey = null, $secondLocalKey = null) |
||
163 | |||
164 | 1 | public static function forceEagerLoading(...$relation) |
|
170 | } |