OwnerStoreFeeDetail.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <?php
  2. namespace App;
  3. use Illuminate\Database\Eloquent\Model;
  4. use App\Traits\ModelLogChanging;
  5. use Illuminate\Database\Eloquent\Relations\BelongsTo;
  6. class OwnerStoreFeeDetail extends Model
  7. {
  8. use ModelLogChanging;
  9. public $fillable = ['owner_fee_detail_id', 'unit_id', 'unit_price', 'amount', 'owner_id', 'store_item_id','owner_price_operation_id'];
  10. // static public $enums = [
  11. // 'type' => [
  12. // '' => 0,
  13. // '退货入库' => 1,
  14. // '新品入库' => 2,
  15. // ],
  16. // ];
  17. //
  18. // function __construct(array $attributes = [])
  19. // {
  20. // foreach (self::$enums as &$enum) {
  21. // $enum = $enum + array_flip($enum);
  22. // }
  23. // parent::__construct($attributes);
  24. // }
  25. //
  26. // public function getTypeAttribute($value)
  27. // {
  28. // if (!$value) return '';
  29. // return self::$enums['type'][$value];
  30. // }
  31. //
  32. // public function setTypeAttribute($value)
  33. // {
  34. // if (!$value) return 0;
  35. // $this->attributes['type'] = self::$enums['type'][$value];
  36. // }
  37. public function ownerFeeDetail(): BelongsTo
  38. {
  39. return $this->belongsTo(OwnerFeeDetail::class);
  40. }
  41. public function unit(): BelongsTo
  42. {
  43. return $this->belongsTo(Unit::class);
  44. }
  45. public function getPriceAttribute(): string
  46. {
  47. return $this->unit_price . '/' . $this->unit->name;
  48. }
  49. public function owner(): BelongsTo
  50. {
  51. return $this->belongsTo(Owner::class);
  52. }
  53. public function storeItem(): BelongsTo
  54. {
  55. return $this->belongsTo(StoreItem::class);
  56. }
  57. public function ownerPriceOperation(): BelongsTo
  58. {
  59. return $this->belongsTo(OwnerPriceOperation::class);
  60. }
  61. }