DischargeTask.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <?php
  2. namespace App;
  3. use App\Traits\ModelTimeFormat;
  4. use Illuminate\Database\Eloquent\Model;
  5. use App\Traits\ModelLogChanging;
  6. use Illuminate\Database\Eloquent\Relations\BelongsTo;
  7. class DischargeTask extends Model
  8. {
  9. use ModelLogChanging;
  10. use ModelTimeFormat;
  11. const status = [
  12. '创建',
  13. '接单',
  14. '作业中',
  15. '完成'
  16. ];
  17. const types = [
  18. '装车',
  19. '卸车',
  20. '翻托',
  21. '包膜'
  22. ];
  23. const units = [
  24. 'm³',
  25. '吨',
  26. '托',
  27. '件'
  28. ];
  29. protected $fillable = [
  30. 'owner_id', // 货主
  31. 'type', // 类型
  32. 'numbers', // 任务编号
  33. 'status', // 状态
  34. 'income_amount', // 数量
  35. 'income_unit', // 单位
  36. 'income_unit_price', // 单价
  37. 'income_total_cost', // 总价
  38. 'income_remark', // 备注
  39. 'facilitator_id', // 卸货商
  40. 'expenditure_amount', // 成本数量
  41. 'expenditure_unit', // 成本单位
  42. 'expenditure_unit_price', // 成本单价
  43. 'expenditure_total_cost', // 成本总价
  44. 'expenditure_remark', // 成本备注
  45. 'income_at', // 预约时间
  46. 'expenditure_at', // 卸货时间
  47. 'warehouse_id', // 仓库
  48. 'created_at', // 创建时间->卸货任务:预约时间->结算报表:日期
  49. ];
  50. // 货主
  51. function owner(): BelongsTo
  52. {
  53. return $this->belongsTo(Owner::class);
  54. }
  55. // 卸货商
  56. function facilitator(): BelongsTo
  57. {
  58. return $this->belongsTo(Facilitator::class);
  59. }
  60. public function scopeFilter($query, $filters)
  61. {
  62. return $filters->apply($query);
  63. }
  64. // 仓库
  65. public function warehouse(): BelongsTo
  66. {
  67. return $this->belongsTo(Warehouse::class);
  68. }
  69. // 任务创建人
  70. public function creator(): BelongsTo
  71. {
  72. return $this->belongsTo(User::class,'creator_id');
  73. }
  74. // 成本录入人
  75. public function constEntry():BelongsTo
  76. {
  77. return $this->belongsTo(User::class,'const_entry_id');
  78. }
  79. }