OwnerBillReport.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. namespace App;
  3. use Illuminate\Database\Eloquent\Model;
  4. use App\Traits\ModelLogChanging;
  5. class OwnerBillReport extends Model
  6. {
  7. use ModelLogChanging;
  8. protected $fillable = [
  9. "owner_id", //项目ID
  10. "counting_month", //结算月
  11. "work_fee", //操作费
  12. "logistic_fee", //物流费
  13. "storage_fee", //仓储费
  14. "confirm_fee", //确认账单金额
  15. "difference", //差额
  16. "confirmed", //确认状态
  17. "other_fee", //其他费用
  18. ];
  19. protected $appends=[
  20. "initial_fee"
  21. ];
  22. public $timestamps=false;
  23. public function owner()
  24. { //货主
  25. return $this->hasOne(Owner::class,"id","owner_id");
  26. }
  27. /* 结算月格式转换,仅截取至月
  28. * 引用:CreateOwnerReport
  29. */
  30. public function getCountingMonthAttribute($value)
  31. {
  32. return substr($value,0,7);
  33. }
  34. public function getInitialFeeAttribute()
  35. { //初始账单金额
  36. return $this->work_fee + $this->logistic_fee + $this->storage_fee + $this->other_fee;
  37. }
  38. }