OwnerReport.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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. "total", //总单量
  14. "current_month_counting_area", //结算月盘点面积
  15. "last_month_counting_area", //结算月上月盘点面积
  16. "owner_bill_report_id" //账单ID
  17. ];
  18. public $timestamps = false;
  19. public function owner()
  20. { //货主
  21. return $this->hasOne(Owner::class,"id","owner_id");
  22. }
  23. public function ownerBillReport()
  24. { //账单
  25. return $this->hasOne(OwnerBillReport::class,"id","owner_bill_report_id");
  26. }
  27. /* 结算月格式转换,仅截取至月
  28. * 引用:CreateOwnerReport
  29. */
  30. public function getCountingMonthAttribute($value)
  31. {
  32. return substr($value,0,7);
  33. }
  34. }