OwnerReport.php 1.0 KB

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