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 | * Get table name from column name |
||
141 | * |
||
142 | * @param string $column |
||
143 | * @return string |
||
144 | */ |
||
145 | protected function getTableFromColumn($column) |
||
151 | |||
152 | /** |
||
153 | * Get table name with alias if different to table name |
||
154 | * |
||
155 | * @param \stdClass $table |
||
156 | * @return string |
||
157 | */ |
||
158 | protected function getTableWithAlias($table) |
||
166 | |||
167 | /** |
||
168 | * Remove a global scope if it exists |
||
169 | * |
||
170 | * @param Builder $query |
||
171 | * @param string $scopeName |
||
172 | * @return Builder |
||
173 | */ |
||
174 | protected function removeGlobalScope($query, $scopeName) |
||
184 | |||
185 | /** |
||
186 | * Check if relation exists in eager loads |
||
187 | * |
||
188 | * @param Builder $builder |
||
189 | * @param \Illuminate\Database\Eloquent\Relations\Relation $relation |
||
190 | * @return bool |
||
191 | */ |
||
192 | protected function isEagerLoaded(Builder $builder, $relation) |
||
198 | } |
||
199 |