| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- <?php
- namespace App;
- use Illuminate\Database\Eloquent\Model;
- use App\Traits\ModelLogChanging;
- use Illuminate\Database\Eloquent\Relations\BelongsTo;
- class OwnerStoreFeeDetail extends Model
- {
- use ModelLogChanging;
- public $fillable = ['owner_fee_detail_id', 'unit_id', 'unit_price', 'amount', 'owner_id', 'store_item_id','owner_price_operation_id'];
- // static public $enums = [
- // 'type' => [
- // '' => 0,
- // '退货入库' => 1,
- // '新品入库' => 2,
- // ],
- // ];
- //
- // 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 ownerFeeDetail(): BelongsTo
- {
- return $this->belongsTo(OwnerFeeDetail::class);
- }
- public function unit(): BelongsTo
- {
- return $this->belongsTo(Unit::class);
- }
- public function getPriceAttribute(): string
- {
- return $this->unit_price . '/' . $this->unit->name;
- }
- public function owner(): BelongsTo
- {
- return $this->belongsTo(Owner::class);
- }
- public function storeItem(): BelongsTo
- {
- return $this->belongsTo(StoreItem::class);
- }
- public function ownerPriceOperation(): BelongsTo
- {
- return $this->belongsTo(OwnerPriceOperation::class);
- }
- }
|