OwnerBillReport.php 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. ];
  18. protected $appends=[
  19. "initial_fee"
  20. ];
  21. public $timestamps=false;
  22. public function owner()
  23. { //货主
  24. return $this->hasOne(Owner::class,"id","owner_id");
  25. }
  26. /* 结算月格式转换,仅截取至月
  27. * 引用:CreateOwnerReport
  28. */
  29. public function getCountingMonthAttribute($value)
  30. {
  31. return substr($value,0,7);
  32. }
  33. public function getInitialFeeAttribute()
  34. { //初始账单金额
  35. return $this->work_fee + $this->logistic_fee + $this->storage_fee;
  36. }
  37. }