1 | <?php |
||
11 | trait HelperMethodTrait |
||
12 | { |
||
13 | |||
14 | /** |
||
15 | * Get relation table name and alias |
||
16 | * |
||
17 | * @param Relation $relation |
||
18 | * @return \stdClass |
||
19 | */ |
||
20 | public function getRelationTables($relation) |
||
30 | |||
31 | /** |
||
32 | * Get the join columns for a relation |
||
33 | * |
||
34 | * @param Relation|BelongsTo|HasOneOrMany $relation |
||
35 | * @return \stdClass |
||
36 | */ |
||
37 | private function getJoinColumns($relation) |
||
50 | |||
51 | /** |
||
52 | * Get the relations from a relation name |
||
53 | * $relationName can be a single relation |
||
54 | * Usage for User model: |
||
55 | * parseRelationNames('customer') returns [$user->customer()] |
||
56 | * parseRelationNames('customer.contact') returns [$user->customer(), $user->customer->contact()] |
||
57 | * |
||
58 | * @param string $relationName |
||
59 | * @return Relation[] |
||
60 | */ |
||
61 | private function parseRelationNames($relationName) |
||
78 | |||
79 | /** |
||
80 | * Add backticks to a table/column |
||
81 | * |
||
82 | * @param string $column |
||
83 | * @return string |
||
84 | */ |
||
85 | private function addBackticks($column) |
||
90 | |||
91 | /** |
||
92 | * Return the sql for a query with the bindings replaced with the binding values |
||
93 | * |
||
94 | * @param Builder $builder |
||
95 | * @return string |
||
96 | */ |
||
97 | private function toSqlWithBindings(Builder $builder) |
||
110 | |||
111 | /** |
||
112 | * Add table name to column name if table name not already included in column name |
||
113 | * |
||
114 | * @param string $table |
||
115 | * @param string $column |
||
116 | * @return string |
||
117 | */ |
||
118 | private function columnWithTableName($table, $column) |
||
122 | |||
123 | /** |
||
124 | * Remove a global scope if it exists |
||
125 | * |
||
126 | * @param Builder $query |
||
127 | * @param string $scopeName |
||
128 | * @return Builder |
||
129 | */ |
||
130 | private function removeGlobalScope($query, $scopeName) |
||
140 | |||
141 | /** |
||
142 | * Check if this model has already been joined to a table or relation |
||
143 | * |
||
144 | * @param Builder $builder |
||
145 | * @param string $table |
||
146 | * @param \Illuminate\Database\Eloquent\Relations\Relation $relation |
||
147 | * @return bool |
||
148 | */ |
||
149 | private function hasJoin(Builder $builder, $table, $relation) |
||
157 | |||
158 | /** |
||
159 | * Check if model is currently joined to $table |
||
160 | * |
||
161 | * @param Builder $builder |
||
162 | * @param string $table |
||
163 | * @return bool |
||
164 | */ |
||
165 | private function isJoined(Builder $builder, $table) |
||
178 | |||
179 | /** |
||
180 | * Check if relation exists in eager loads |
||
181 | * |
||
182 | * @param Builder $builder |
||
183 | * @param \Illuminate\Database\Eloquent\Relations\Relation $relation |
||
184 | * @return bool |
||
185 | */ |
||
186 | private function isEagerLoaded(Builder $builder, $relation) |
||
192 | } |
||
193 |