select()) && count($data) ? $data->toArray() : []; foreach ($data as &$item) { $item['industry_name'] = Industry::where('id', 'IN', $item['industry_id'])->column('name'); $item['industry_name'] = $item['industry_name'] ? implode(',', $item['industry_name']) : []; $item['industry_id'] = $item['industry_id'] ? explode(',', $item['industry_id']) : []; // $item['address'] = $item['address'] ? explode(',', $item['address']) : []; // $item['facilities'] = $item['facilities'] ? explode(',', $item['facilities']) : []; // $item['day_time'] = $item['day_time'] ? explode(' - ', $item['day_time']) : []; } $count = self::setWhere($where)->count(); return ['count' => $count, 'list' => $data]; } public static function setWhere($where) { $model = (new self); if ($where['key_word']) { $model = $model->where('name|phone', 'like', '%' . $where['key_word'] . '%'); } if ($where['industry_id']) { $model = $model->where('industry_id', $where['industry_id']); } if ($where['version']) { $model = $model->where('version', $where['version']); } if ($where['data']) { $model = self::getModelTime($where, $model, 'add_time'); } return $model; } }