1、获取别名
Hotel::query()
->where('city_id', $city_id)
->get(['hotel_name as name', 'id as value'])
->toArray();
//或者
Hotel::query()
->where('city_id', $city_id)
->select('hotel_name as name', 'id as value')
->toArray();
复制代码
Hotel::query()
->where('city_id', $city_id)
->get(['hotel_name as name', 'id as value'])
->toArray();
//或者
Hotel::query()
->where('city_id', $city_id)
->select('hotel_name as name', 'id as value')
->toArray();
复制代码