| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- <?php
- namespace App;
- use Illuminate\Database\Eloquent\Model;
- use App\Traits\ModelLogChanging;
- use Illuminate\Database\Eloquent\Relations\BelongsTo;
- class OwnerBillReportArchive extends Model
- {
- use ModelLogChanging;
- public $fillable = ['owner_bill_report_id', 'owner_id', 'counting_month', 'type', 'archiver_id', 'archived_at', 'information'];
- public $dates = [
- 'archived_at',
- 'counting_month'
- ];
- public $casts = [
- 'information' => 'array',
- ];
- public $timestamps = false;
- static public $enums = [
- 'type' => [
- '' => 0,
- '仓储费' => 1,
- '快递费-合计' => 2,
- '入库费-合计' => 3,
- '出库费-合计' => 4,
- '物流费' => 5,
- '包材费' => 6,
- '加工费' => 7,
- '杂项费' => 8,
- '卸货费' => 9,
- '总费用' => 10,
- '理赔费' => 11,
- ],
- ];
- function __construct(array $attributes = [])
- {
- foreach (self::$enums as &$enum) {
- $enum=$enum+array_flip($enum);
- }
- parent::__construct($attributes);
- }
- public function getTypeAttribute($value)
- {
- if (!$value) return '';
- return self::$enums['type'][$value];
- }
- public function setTypeAttribute($value)
- {
- if (!$value) return 0;
- $this->attributes['type'] = self::$enums['type'][$value];
- }
- public function ownerBillReport(): BelongsTo
- {
- return $this->belongsTo(OwnerBillReport::class);
- }
- public function owner(): BelongsTo
- {
- return $this->belongsTo(Owner::class);
- }
- }
|