<?php namespace App\Http\Transformers; use App\Http\Services\DepartmentService; use App\Model\SupplierChannelModel; class SupplierExaminationTransformer { public function transformList($list) { foreach ($list as &$item) { $item['purchase_department'] = (new DepartmentService())->getDepartmentNameByUserName($item['purchase_name']); $item['sales_department'] = $item['sales_name'] ? (new DepartmentService())->getDepartmentNameByUserName($item['sales_name']) : ''; $item['create_time'] = $item['create_time'] ? date('Y-m-d H:i:s', $item['create_time']) : ''; $item['update_time'] = $item['update_time'] ? date('Y-m-d H:i:s', $item['update_time']) : ''; $item['examine_time'] = $item['examine_time'] ? date('Y-m-d', $item['examine_time']) : ''; $item['stock_in_date'] = $item['stock_in_date'] ? date('Y-m-d', $item['stock_in_date']) : ''; $item['abnormal_level'] = $item['abnormal_level'] ? array_get(config('field.SupplierAbnormalLevel'), $item['abnormal_level']) : ''; } unset($item); return $list; } }