"9-11", 1 => "13-17", ]; //时长 映射PERIOD常量 const HOUR=[ 0 => 3, 1 => 5 ]; //状态 const STATUS=[ 0 => "待收", 1 => "取消", 2 => "完成", 3 => "未送达", ]; protected $appends=[ "period" ]; public function cars() { //车辆 return $this->hasMany(DeliveryAppointmentCar::class,"delivery_appointment_id","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 getPeriodAttribute(){ return self::PERIOD[$this["date_period"]]; } }