| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- <?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,
- ],
- ];
- 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);
- }
- }
|