DeliveryAppointment.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. namespace App;
  3. use Illuminate\Database\Eloquent\Model;
  4. use App\Traits\ModelLogChanging;
  5. class DeliveryAppointment extends Model
  6. {
  7. use ModelLogChanging;
  8. protected $fillable=[
  9. "user_id",
  10. "owner_id",
  11. "procurement_number",
  12. "asn_number",
  13. "warehouse_id",
  14. "tonne",
  15. "cubic_meter",
  16. "box_amount",
  17. "capacity",
  18. "appointment_date",
  19. "date_period",
  20. "status",
  21. ];
  22. //时段 映射date_period字段
  23. const PERIOD=[
  24. 0 => "9-11",
  25. 1 => "13-17",
  26. ];
  27. //时长 映射PERIOD常量
  28. const HOUR=[
  29. 0 => 3,
  30. 1 => 5
  31. ];
  32. //状态
  33. const STATUS=[
  34. 0 => "待收",
  35. 1 => "取消",
  36. 2 => "完成",
  37. ];
  38. public function cars()
  39. { //车辆
  40. return $this->hasMany(DeliveryAppointmentCar::class,"delivery_appointment_id","id");
  41. }
  42. public function details()
  43. { //明细
  44. return $this->hasMany(DeliveryAppointmentDetail::class);
  45. }
  46. public function user()
  47. { //用户
  48. return $this->belongsTo(User::class);
  49. }
  50. public function owner()
  51. { //货主
  52. return $this->belongsTo(Owner::class);
  53. }
  54. public function warehouse()
  55. { //仓库
  56. return $this->belongsTo(Warehouse::class);
  57. }
  58. }