123456789101112131415161718192021222324252627282930313233343536373839 |
- <?php
- namespace App\Http\Services\V1_1;
- use App\Generated\V1_1\Messages\City\SearchMessage;
- use App\Generated\V1_1\Messages\City\GetListMessage;
- use App\Models\Common\CityModel;
- class CityService
- {
- /**
- * 城市列表
- * @param GetListMessage $message
- */
- public function getList(GetListMessage $message)
- {
- $provinces = CityModel::groupBy("province")->pluck('province');
- $data = array();
- foreach ($provinces as $province) {
- $data[$province] = CityModel::where("province", $province)->pluck('city');
- }
- $message->setResponse($data);
- }
- /**
- * 城市搜索
- * @param SearchMessage $message
- */
- public function search(SearchMessage $message)
- {
- $keyword = $message->getKeyword();
- $citys = CityModel::where("city", "like", "%{$keyword}%")->get();
- $message->setResponse($citys);
- }
- }
|