"09-12", 1 => "13-15", 2 => "15-17", ]; //时长 映射PERIOD常量 const HOUR=[ 0 => 3, 1 => 2, 2 => 2, ]; //状态 const STATUS=[ 0 => "待收", 1 => "取消", 2 => "完成", 3 => "已逾期", 4 => "逾期收货", ]; //类型标记 const TYPE = [ 0 => "质检", ]; //禁止送货日期列表 REDIS key const BAN = "DELIVERY_BAN_ON_DATE"; protected $appends=[ "period" ]; public function cars() { //车辆 return $this->hasMany(DeliveryAppointmentCar::class,"delivery_appointment_id","id"); } public function car() { //单车辆 return $this->belongsTo(DeliveryAppointmentCar::class,"id","delivery_appointment_id"); } public function details() { //明细 return $this->hasMany(DeliveryAppointmentDetail::class); } public function user() { //用户 return $this->belongsTo(User::class); } public function owner() { //货主 return $this->belongsTo(Owner::class); } public function warehouse() { //仓库 return $this->belongsTo(Warehouse::class); } public function logistic() { //快递 return $this->belongsTo(Logistic::class); } /** * 2021-08-05 在此之前所有 period为1的时间都为13-17 * * @return string */ public function getPeriodAttribute(){ /** @var Carbon $create */ $create = $this["created_at"]; if ($create->lt(Carbon::parse("2021-08-05")) && $this["date_period"]==1)return '13-17'; return self::PERIOD[$this["date_period"]]; } }