OwnerReport.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. namespace App;
  3. use App\Traits\ModelTimeFormat;
  4. use Carbon\Carbon;
  5. use Illuminate\Database\Eloquent\Model;
  6. use App\Traits\ModelLogChanging;
  7. class OwnerReport extends Model
  8. {
  9. use ModelLogChanging;
  10. use ModelTimeFormat;
  11. protected $fillable = [
  12. "owner_id", //货主ID
  13. "counting_month", //结算月
  14. "daily_average_order_amount", //日均单量
  15. "total", //总单量
  16. "current_month_counting_area", //结算月盘点面积
  17. "last_month_counting_area", //结算月上月盘点面积
  18. "owner_bill_report_id" //账单ID
  19. ];
  20. public $timestamps = false;
  21. public function owner()
  22. { //货主
  23. return $this->hasOne(Owner::class,"id","owner_id");
  24. }
  25. public function ownerBillReport()
  26. { //账单
  27. return $this->hasOne(OwnerBillReport::class,"id","owner_bill_report_id");
  28. }
  29. /* 结算月格式转换,仅截取至月
  30. * 引用:CreateOwnerReport
  31. */
  32. public function getCountingMonthAttribute($value)
  33. {
  34. return substr($value,0,7);
  35. }
  36. }