OrderFreeze.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. namespace App;
  3. use App\Traits\ModelTimeFormat;
  4. use Illuminate\Database\Eloquent\Model;
  5. use App\Traits\LogModelChanging;
  6. class OrderFreeze extends Model
  7. {
  8. use LogModelChanging;
  9. use ModelTimeFormat;
  10. protected $fillable = [
  11. "status","logistic_id","province_id","city_id","district_id","town_id","street_id"
  12. ];
  13. const status=[
  14. 0 => "冻结",
  15. 1 => "解冻",
  16. ];
  17. public function logistic()
  18. { //承运商
  19. return $this->belongsTo(Logistic::class);
  20. }
  21. public function province()
  22. { //省
  23. return $this->belongsTo(Region::class)->where("type",1);
  24. }
  25. public function city()
  26. { //市
  27. return $this->belongsTo(Region::class)->where("type",2);
  28. }
  29. public function district()
  30. { //区县
  31. return $this->belongsTo(Region::class)->where("type",3);
  32. }
  33. public function town()
  34. { //乡镇
  35. return $this->belongsTo(Region::class)->where("type",4);
  36. }
  37. public function street()
  38. { //村街
  39. return $this->belongsTo(Region::class)->where("type",5);
  40. }
  41. }