BasePostageRegion.php 790 B

12345678910111213141516171819202122232425262728
  1. <?php
  2. namespace app\data\model;
  3. use think\admin\Model;
  4. use think\db\Query;
  5. /**
  6. * 快递配送模型
  7. * Class BasePostageRegion
  8. * @package app\data\model
  9. * @method static static|Query level($level)
  10. */
  11. class BasePostageRegion extends Model
  12. {
  13. public static function hot(){
  14. $hot=['北京市','南京市','成都市','重庆市','西安市','广州市','苏州市','杭州市','武汉市'];
  15. return app()->cache->remember('app_area_hot',function () use ($hot) {
  16. return self::whereIn('name',$hot)->level(2)->field(['id','name'])->select();
  17. },0);
  18. }
  19. public function scopeLevel(Query $query,$level){
  20. $query->where('level',$level);
  21. }
  22. public static function getCity(){
  23. return self::where('level','<=',2)->select();
  24. }
  25. }