OwnerLogisticFeeReport.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. namespace App;
  3. use Illuminate\Database\Eloquent\Model;
  4. use App\Traits\ModelLogChanging;
  5. use Illuminate\Database\Eloquent\Relations\BelongsTo;
  6. class OwnerLogisticFeeReport extends Model
  7. {
  8. use ModelLogChanging;
  9. public $fillable = [
  10. 'owner_logistic_sum_fee_report_id',//
  11. 'logistic_id',//承运商
  12. 'province_id', //省份
  13. 'counted_date',//统计月份
  14. 'initial_weight',//首重
  15. 'initial_weight_price',//首重价格
  16. 'initial_amount', //数量
  17. 'additional_weight', //续重
  18. 'additional_price', //续重价格
  19. 'additional_amount',//续重数量
  20. 'fee',//费用
  21. 'tax_fee',//税费
  22. 'owner_id'//货主
  23. ];
  24. protected $appends = [
  25. 'initial_weight_fee',
  26. 'additional_weight_fee'
  27. ];
  28. public $timestamps = false;
  29. public function logistic(): BelongsTo
  30. {
  31. return $this->belongsTo(Logistic::class);
  32. }
  33. public function province(): BelongsTo
  34. {
  35. return $this->belongsTo(Province::class);
  36. }
  37. public function getInitialWeightFeeAttribute(): string
  38. {
  39. return number_format($this->initial_weight * $this->initial_weight_price * $this->initial_amount, 2);
  40. }
  41. public function getAdditionalWeightFeeAttribute(): string
  42. {
  43. return number_format($this->additional_weight * $this->additional_price * $this->additional_amount, 2);
  44. }
  45. }