| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- <?php
- namespace App;
- use App\Traits\ModelTimeFormat;
- use Carbon\Carbon;
- use Illuminate\Database\Eloquent\Model;
- use App\Traits\ModelLogChanging;
- class OwnerReport extends Model
- {
- use ModelLogChanging;
- use ModelTimeFormat;
- protected $fillable = [
- "owner_id", //货主ID
- "counting_month", //结算月
- "daily_average_order_amount", //日均单量
- "to_business_quantity", //ToB单量
- "to_customer_quantity", //ToC单量
- "current_month_counting_area", //结算月盘点面积
- "last_month_counting_area", //结算月上月盘点面积
- "owner_bill_report_id" //账单ID
- ];
- public $timestamps = false;
- protected $appends=[
- "total"
- ];
- public function owner()
- { //货主
- return $this->hasOne(Owner::class,"id","owner_id");
- }
- public function ownerBillReport()
- { //账单
- return $this->hasOne(OwnerBillReport::class,"id","owner_bill_report_id");
- }
- /* 结算月格式转换,仅截取至月
- * 引用:CreateOwnerReport
- */
- public function getCountingMonthAttribute($value)
- {
- return substr($value,0,7);
- }
- public function getTotalAttribute()
- { //总单量
- return $this->to_business_quantity + $this->to_customer_quantity;
- }
- }
|