Address.php 1001 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. namespace app\common\models;
  3. /**
  4. * Created by PhpStorm.
  5. * Author: 芸众商城 www.yunzshop.com
  6. * Date: 2017/2/27
  7. * Time: 上午9:11
  8. */
  9. class Address extends BaseModel
  10. {
  11. public $timestamps = false;
  12. public $table = 'yz_address';
  13. protected $guarded = [''];
  14. protected $fillable = [''];
  15. public static function getProvince()
  16. {
  17. return self::where('level', '1')->get();
  18. }
  19. public static function getCityByParentId($parentId)
  20. {
  21. return self::where('parentid', $parentId)
  22. ->where('level', '2')
  23. ->get();
  24. }
  25. public static function getAreaByParentId($parentId)
  26. {
  27. return self::where('parentid', $parentId)
  28. ->where('level', '3')
  29. ->get();
  30. }
  31. public static function getAddress($data)
  32. {
  33. return self::whereIn('id', $data)
  34. ->get();
  35. }
  36. public function hasOneParent()
  37. {
  38. return $this->hasOne(self::class, 'id', 'parentid');
  39. }
  40. }