| Total Complexity | 4 |
| Total Lines | 32 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 5 | trait HasTableAlias |
||
| 6 | { |
||
| 7 | /** |
||
| 8 | * Qualify the given column name by the model's table. |
||
| 9 | * |
||
| 10 | * @param string $column |
||
| 11 | * @return string |
||
| 12 | */ |
||
| 13 | 112 | public function qualifyColumn($column) |
|
| 14 | { |
||
| 15 | 112 | if (str_contains($column, '.')) { |
|
| 16 | 2 | return $column; |
|
| 17 | } |
||
| 18 | |||
| 19 | 112 | $table = $this->getTable(); |
|
|
|
|||
| 20 | |||
| 21 | 112 | if (str_contains($table, ' as ')) { |
|
| 22 | 17 | $table = explode(' as ', $table)[1]; |
|
| 23 | } |
||
| 24 | |||
| 25 | 112 | return $table.'.'.$column; |
|
| 26 | } |
||
| 27 | |||
| 28 | /** |
||
| 29 | * Set an alias for the model's table. |
||
| 30 | * |
||
| 31 | * @param string $alias |
||
| 32 | * @return $this |
||
| 33 | */ |
||
| 34 | 2 | public function setAlias($alias) |
|
| 37 | } |
||
| 38 | } |
||
| 39 |