You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

48 lines
954 B

  1. <?php
  2. namespace App\Http\Model;
  3. use Illuminate\Database\Eloquent\Model;
  4. use App\Common\Token;
  5. class Region extends BaseModel
  6. {
  7. //地区
  8. protected $table = 'region';
  9. public $timestamps = false;
  10. public static function getRegionName($id)
  11. {
  12. $res = self::where('id', $id)->value('name');
  13. if (!empty($res))
  14. {
  15. return $res;
  16. }
  17. return false;
  18. }
  19. public static function getList($parent_id=86)
  20. {
  21. $key = 'region';
  22. if (!$model = Cache::get($key))
  23. {
  24. $model = self::where('parent_id', $parent_id)->get()->toArray();
  25. Cache::put($key, $model, 10);
  26. }
  27. return $model;
  28. }
  29. public static function getOne($id)
  30. {
  31. $res = self::where('id', $id)->first()->toArray();
  32. if (!empty($res))
  33. {
  34. return $res;
  35. }
  36. return false;
  37. }
  38. }