| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- <?php
- namespace App;
- use App\Traits\ModelTimeFormat;
- use Illuminate\Database\Eloquent\Model;
- use App\Traits\ModelLogChanging;
- use Illuminate\Database\Eloquent\Relations\BelongsTo;
- class DischargeTask extends Model
- {
- use ModelLogChanging;
- use ModelTimeFormat;
- const status = [
- '创建',
- '接单',
- '作业中',
- '完成'
- ];
- const types = [
- '装车',
- '卸车',
- '翻托',
- '包膜'
- ];
- const units = [
- 'm³',
- '吨',
- '托',
- '件'
- ];
- protected $fillable = [
- 'owner_id', // 货主
- 'type', // 类型
- 'numbers', // 任务编号
- 'status', // 状态
- 'income_amount', // 数量
- 'income_unit', // 单位
- 'income_unit_price', // 单价
- 'income_total_cost', // 总价
- 'income_remark', // 备注
- 'facilitator_id', // 卸货商
- 'expenditure_amount', // 成本数量
- 'expenditure_unit', // 成本单位
- 'expenditure_unit_price', // 成本单价
- 'expenditure_total_cost', // 成本总价
- 'expenditure_remark', // 成本备注
- 'income_at', // 预约时间
- 'expenditure_at', // 卸货时间
- 'warehouse_id', // 仓库
- 'created_at', // 创建时间->卸货任务:预约时间->结算报表:日期
- ];
- // 货主
- function owner(): BelongsTo
- {
- return $this->belongsTo(Owner::class);
- }
- // 卸货商
- function facilitator(): BelongsTo
- {
- return $this->belongsTo(Facilitator::class);
- }
- public function scopeFilter($query, $filters)
- {
- return $filters->apply($query);
- }
- // 仓库
- public function warehouse(): BelongsTo
- {
- return $this->belongsTo(Warehouse::class);
- }
- // 任务创建人
- public function creator(): BelongsTo
- {
- return $this->belongsTo(User::class,'creator_id');
- }
- // 成本录入人
- public function constEntry():BelongsTo
- {
- return $this->belongsTo(User::class,'const_entry_id');
- }
- }
|