1 | <?php |
||
11 | trait HelperMethodTrait |
||
12 | { |
||
13 | |||
14 | /** |
||
15 | * Get the join columns for a relation |
||
16 | * |
||
17 | * @param Relation|BelongsTo|HasOneOrMany $relation |
||
18 | * @return \stdClass |
||
19 | */ |
||
20 | private function getJoinColumns($relation) |
||
33 | |||
34 | /** |
||
35 | * Get the relations from a relation name |
||
36 | * $relationName can be a single relation |
||
37 | * Usage for User model: |
||
38 | * parseRelationNames('customer') returns [$user->customer()] |
||
39 | * parseRelationNames('customer.contact') returns [$user->customer(), $user->customer->contact()] |
||
40 | * |
||
41 | * @param string $relationName |
||
42 | * @return Relation[] |
||
43 | */ |
||
44 | private function parseRelationNames($relationName) |
||
61 | |||
62 | /** |
||
63 | * Add backticks to a table/column |
||
64 | * |
||
65 | * @param string $column |
||
66 | * @return string |
||
67 | */ |
||
68 | private function addBackticks($column) |
||
73 | |||
74 | /** |
||
75 | * Return the sql for a query with the bindings replaced with the binding values |
||
76 | * |
||
77 | * @param Builder $builder |
||
78 | * @return string |
||
79 | */ |
||
80 | private function toSqlWithBindings(Builder $builder) |
||
93 | |||
94 | /** |
||
95 | * Add table name to column name if table name not already included in column name |
||
96 | * |
||
97 | * @param string $table |
||
98 | * @param string $column |
||
99 | * @return string |
||
100 | */ |
||
101 | private function columnWithTableName($table, $column) |
||
105 | |||
106 | /** |
||
107 | * Remove a global scope if it exists |
||
108 | * |
||
109 | * @param Builder $query |
||
110 | * @param string $scopeName |
||
111 | * @return Builder |
||
112 | */ |
||
113 | private function removeGlobalScope($query, $scopeName) |
||
123 | |||
124 | /** |
||
125 | * Check if this model has already been joined to a table or relation |
||
126 | * |
||
127 | * @param Builder $builder |
||
128 | * @param string $table |
||
129 | * @param \Illuminate\Database\Eloquent\Relations\Relation $relation |
||
130 | * @return bool |
||
131 | */ |
||
132 | private function hasJoin(Builder $builder, $table, $relation) |
||
140 | |||
141 | /** |
||
142 | * Check if model is currently joined to $table |
||
143 | * |
||
144 | * @param Builder $builder |
||
145 | * @param string $table |
||
146 | * @return bool |
||
147 | */ |
||
148 | private function isJoined(Builder $builder, $table) |
||
161 | |||
162 | /** |
||
163 | * Check if relation exists in eager loads |
||
164 | * |
||
165 | * @param Builder $builder |
||
166 | * @param \Illuminate\Database\Eloquent\Relations\Relation $relation |
||
167 | * @return bool |
||
168 | */ |
||
169 | private function isEagerLoaded(Builder $builder, $relation) |
||
175 | } |
||
176 |