1 | <?php |
||
2 | |||
3 | namespace Znck\Eloquent\Traits; |
||
4 | |||
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 | public function qualifyColumn($column) |
||
14 | { |
||
15 | if (str_contains($column, '.')) { |
||
16 | return $column; |
||
17 | } |
||
18 | |||
19 | $table = $this->getTable(); |
||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||
20 | |||
21 | if (str_contains($table, ' as ')) { |
||
22 | $table = explode(' as ', $table)[1]; |
||
23 | } |
||
24 | |||
25 | return $table.'.'.$column; |
||
26 | } |
||
27 | } |
||
28 |