1 | <?php |
||
9 | trait HelperMethodTrait |
||
10 | { |
||
11 | |||
12 | /** |
||
13 | * Get the relations from a relation name |
||
14 | * $relationName can be a single relation |
||
15 | * Usage for User model: |
||
16 | * parseRelationNames('customer') returns [$user->customer()] |
||
17 | * parseRelationNames('customer.contact') returns [$user->customer(), $user->customer->contact()] |
||
18 | * |
||
19 | * @param string $relationName |
||
20 | * @return Relation[] |
||
21 | */ |
||
22 | private function parseRelationNames($relationName) |
||
39 | |||
40 | /** |
||
41 | * Add backticks to a table/column |
||
42 | * |
||
43 | * @param string $column |
||
44 | * @return string |
||
45 | */ |
||
46 | private function addBackticks($column) |
||
51 | |||
52 | /** |
||
53 | * Return the sql for a query with the bindings replaced with the binding values |
||
54 | * |
||
55 | * @param Builder $builder |
||
56 | * @return string |
||
57 | */ |
||
58 | private function toSqlWithBindings(Builder $builder) |
||
71 | |||
72 | /** |
||
73 | * Add table name to column name if table name not already included in column name |
||
74 | * |
||
75 | * @param string $table |
||
76 | * @param string $column |
||
77 | * @return string |
||
78 | */ |
||
79 | private function columnWithTableName($table, $column) |
||
83 | |||
84 | /** |
||
85 | * Remove a global scope if it exists |
||
86 | * |
||
87 | * @param Builder $query |
||
88 | * @param string $scopeName |
||
89 | * @return Builder |
||
90 | */ |
||
91 | private function removeGlobalScope($query, $scopeName) |
||
101 | |||
102 | /** |
||
103 | * Check if this model has already been joined to a table or relation |
||
104 | * |
||
105 | * @param Builder $builder |
||
106 | * @param string $table |
||
107 | * @param \Illuminate\Database\Eloquent\Relations\Relation $relation |
||
108 | * @return bool |
||
109 | */ |
||
110 | private function hasJoin(Builder $builder, $table, $relation) |
||
118 | |||
119 | /** |
||
120 | * Check if model is currently joined to $table |
||
121 | * |
||
122 | * @param Builder $builder |
||
123 | * @param string $table |
||
124 | * @return bool |
||
125 | */ |
||
126 | private function isJoined(Builder $builder, $table) |
||
139 | |||
140 | /** |
||
141 | * Check if relation exists in eager loads |
||
142 | * |
||
143 | * @param Builder $builder |
||
144 | * @param \Illuminate\Database\Eloquent\Relations\Relation $relation |
||
145 | * @return bool |
||
146 | */ |
||
147 | private function isEagerLoaded(Builder $builder, $relation) |
||
153 | } |