| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- <?php
- namespace App;
- use App\Traits\ModelTimeFormat;
- use Illuminate\Database\Eloquent\Model;
- use App\Traits\ModelLogChanging;
- class DeliveryAppointment extends Model
- {
- use ModelLogChanging;
- use ModelTimeFormat;
- protected $fillable=[
- "user_id",
- "owner_id",
- "procurement_number",
- "asn_number",
- "warehouse_id",
- "tonne",
- "cubic_meter",
- "box_amount",
- "capacity",
- "appointment_date",
- "date_period",
- "status",
- "logistic_id",
- "logistic_number",
- "type_mark",
- "remark",
- ];
- //时段 映射date_period字段 必须有序 否则展示数据错乱
- const PERIOD=[
- 0 => "09-11",
- 1 => "13-17",
- ];
- //时长 映射PERIOD常量
- const HOUR=[
- 0 => 3,
- 1 => 5
- ];
- //状态
- const STATUS=[
- 0 => "待收",
- 1 => "取消",
- 2 => "完成",
- 3 => "已逾期",
- ];
- //类型标记
- const TYPE = [
- 0 => "质检",
- ];
- 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 logistic()
- { //快递
- return $this->belongsTo(Logistic::class);
- }
- public function getPeriodAttribute(){
- return self::PERIOD[$this["date_period"]];
- }
- }
|