| Total Complexity | 5 |
| Total Lines | 36 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 13 | class Hook extends TypesHook |
||
| 14 | { |
||
| 15 | /** |
||
| 16 | * @param \Illuminate\Database\Query\Builder $query |
||
| 17 | * @param SelectModel $column |
||
| 18 | * @return mixed|void |
||
| 19 | */ |
||
| 20 | public function query($query, $column) |
||
| 21 | { |
||
| 22 | if($column->getOptionsFromTable()) { |
||
| 23 | $option = $column->getOptionsFromTable(); |
||
| 24 | $query->join($option["table"],$option["table"].'.'.$option["key_field"],"=", $column->getName()); |
||
| 25 | $query->addSelect($option['table'].'.'.$option['display_field'].' as '.$option['table'].'_'.$option['display_field']); |
||
| 26 | } |
||
| 27 | return $query; |
||
| 28 | } |
||
| 29 | |||
| 30 | /** |
||
| 31 | * @param $row |
||
| 32 | * @param $column SelectModel |
||
| 33 | */ |
||
| 34 | public function indexRender($row, $column) |
||
| 35 | { |
||
| 36 | if($column->getOptionsFromTable()) { |
||
| 37 | $option = $column->getOptionsFromTable(); |
||
| 38 | return $row->{ $option['table'].'_'.$option['display_field'] }; |
||
| 39 | }else{ |
||
| 40 | $option = $column->getOptions(); |
||
| 41 | $key = $row->{ $column->getField() }; |
||
| 42 | return @$option[ $key ]; |
||
| 43 | } |
||
| 44 | } |
||
| 45 | |||
| 46 | public function detailRender($row, $column) |
||
| 49 | } |
||
| 50 | |||
| 51 | } |