1 | <?php |
||
21 | trait HelperMethodTrait |
||
22 | { |
||
23 | |||
24 | /** |
||
25 | * Get relation table name and alias |
||
26 | * |
||
27 | * @param Relation $relation |
||
28 | * @return \stdClass |
||
29 | */ |
||
30 | protected function getRelationTables($relation) |
||
40 | |||
41 | /** |
||
42 | * Get the join columns for a relation |
||
43 | * |
||
44 | * @param Relation|BelongsTo|HasOneOrMany $relation |
||
45 | * @return \stdClass |
||
46 | */ |
||
47 | protected function getJoinColumns($relation) |
||
60 | |||
61 | /** |
||
62 | * Get the relations from a relation name |
||
63 | * $relationName can be a single relation |
||
64 | * Usage for User model: |
||
65 | * parseRelationNames('customer') returns [$user->customer()] |
||
66 | * parseRelationNames('customer.contact') returns [$user->customer(), $user->customer->contact()] |
||
67 | * |
||
68 | * @param string $relationName |
||
69 | * @return Relation[] |
||
70 | */ |
||
71 | protected function parseRelationNames($relationName) |
||
88 | |||
89 | /** |
||
90 | * Add backticks to a table/column |
||
91 | * |
||
92 | * @param string $column |
||
93 | * @return string |
||
94 | */ |
||
95 | protected function addBackticks($column) |
||
100 | |||
101 | /** |
||
102 | * Return the sql for a query with the bindings replaced with the binding values |
||
103 | * |
||
104 | * @param Builder $builder |
||
105 | * @return string |
||
106 | */ |
||
107 | protected function toSqlWithBindings(Builder $builder) |
||
126 | |||
127 | /** |
||
128 | * Add table name to column name if table name not already included in column name |
||
129 | * |
||
130 | * @param string $table |
||
131 | * @param string $column |
||
132 | * @return string |
||
133 | */ |
||
134 | protected function columnWithTableName($table, $column) |
||
138 | |||
139 | /** |
||
140 | * Remove a global scope if it exists |
||
141 | * |
||
142 | * @param Builder $query |
||
143 | * @param string $scopeName |
||
144 | * @return Builder |
||
145 | */ |
||
146 | protected function removeGlobalScope($query, $scopeName) |
||
156 | |||
157 | /** |
||
158 | * Check if this model has already been joined to a table or relation |
||
159 | * |
||
160 | * @param Builder $builder |
||
161 | * @param string $table |
||
162 | * @param \Illuminate\Database\Eloquent\Relations\Relation $relation |
||
163 | * @return bool |
||
164 | */ |
||
165 | protected function hasJoin(Builder $builder, $table, $relation) |
||
173 | |||
174 | /** |
||
175 | * Check if model is currently joined to $table |
||
176 | * |
||
177 | * @param Builder $builder |
||
178 | * @param string $table |
||
179 | * @return bool |
||
180 | */ |
||
181 | protected function isJoinedToTable(Builder $builder, $table) |
||
194 | |||
195 | /** |
||
196 | * Check if relation exists in eager loads |
||
197 | * |
||
198 | * @param Builder $builder |
||
199 | * @param \Illuminate\Database\Eloquent\Relations\Relation $relation |
||
200 | * @return bool |
||
201 | */ |
||
202 | protected function isEagerLoaded(Builder $builder, $relation) |
||
208 | } |
||
209 |