1 | <?php |
||
19 | trait HelperMethodTrait |
||
20 | { |
||
21 | |||
22 | /** |
||
23 | * Get relation table name and alias |
||
24 | * |
||
25 | * @param Relation $relation |
||
26 | * @return \stdClass |
||
27 | */ |
||
28 | protected function getRelationTables($relation) |
||
38 | |||
39 | /** |
||
40 | * Get the relations from a relation name |
||
41 | * $relationName can be a single relation |
||
42 | * Usage for User model: |
||
43 | * parseRelationNames('customer') returns [$user->customer()] |
||
44 | * parseRelationNames('customer.contact') returns [$user->customer(), $user->customer->contact()] |
||
45 | * |
||
46 | * @param string $relationName |
||
47 | * @return Relation[] |
||
48 | */ |
||
49 | protected function parseRelationNames($relationName) |
||
66 | |||
67 | /** |
||
68 | * Add backticks to a table/column |
||
69 | * |
||
70 | * @param string $column |
||
71 | * @return string |
||
72 | */ |
||
73 | protected function addBackticks($column) |
||
78 | |||
79 | /** |
||
80 | * Return the sql for a query with the bindings replaced with the binding values |
||
81 | * |
||
82 | * @param Builder $builder |
||
83 | * @return string |
||
84 | */ |
||
85 | protected function toSqlWithBindings(Builder $builder) |
||
104 | |||
105 | /** |
||
106 | * Add table name to column name if table name not already included in column name |
||
107 | * |
||
108 | * @param string $table |
||
109 | * @param string $column |
||
110 | * @return string |
||
111 | */ |
||
112 | protected function columnWithTableName($table, $column) |
||
116 | |||
117 | /** |
||
118 | * Get table name from column name |
||
119 | * |
||
120 | * @param string $column |
||
121 | * @return string |
||
122 | */ |
||
123 | protected function getTableFromColumn($column) |
||
129 | |||
130 | /** |
||
131 | * Get table name with alias if different to table name |
||
132 | * |
||
133 | * @param \stdClass $table |
||
134 | * @return string |
||
135 | */ |
||
136 | protected function getTableWithAlias($table) |
||
144 | |||
145 | /** |
||
146 | * Remove a global scope if it exists |
||
147 | * |
||
148 | * @param Builder $query |
||
149 | * @param string $scopeName |
||
150 | * @return Builder |
||
151 | */ |
||
152 | protected function removeGlobalScope($query, $scopeName) |
||
162 | } |
||
163 |