12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- <?php
- namespace App\Services;
- use App\Models\SysRegion;
- use Slowlyo\OwlAdmin\Services\AdminService;
- /**
- * 行政区划
- *
- * @method SysRegion getModel()
- * @method SysRegion|\Illuminate\Database\Query\Builder query()
- */
- class SysRegionService extends AdminService
- {
- protected string $modelName = SysRegion::class;
- /**
- * 获取省份列表
- */
- public function getProvinceList()
- {
- return $this->query()->where('depth', 1)->get();
- }
- /**
- * 获取省份(与getProvinceList相同)
- */
- public function getProvince()
- {
- return $this->getProvinceList();
- }
- /**
- * 获取指定省份的城市列表
- */
- public function getCity($provinceId)
- {
- return $this->query()->where('parent_id', $provinceId)
- ->where('depth', 2)
- ->get();
- }
- /**
- * 获取指定城市的区域列表
- */
- public function getArea($cityId)
- {
- return $this->query()->where('parent_id', $cityId)
- ->where('depth', 3)
- ->get();
- }
- /**
- * 获取所有省份
- */
- public function getAllProvince()
- {
- return $this->getProvinceList();
- }
- /**
- * 获取所有城市
- */
- public function getAllCity()
- {
- return $this->query()->where('depth', 2)->get();
- }
- /**
- * 获取所有区域
- */
- public function getAllArea()
- {
- return $this->query()->where('depth', 3)->get();
- }
- /**
- * 获取所有街道
- */
- public function getAllStreet()
- {
- return $this->query()->where('depth', 4)->get();
- }
- }
|