OwnerStoreFeeDetail.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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 = [
  10. 'owner_fee_detail_id',
  11. 'unit_id',
  12. 'unit_price', //单价
  13. 'amount', //数量
  14. 'owner_id', //货主
  15. 'store_item_id',
  16. 'owner_price_operation_id'
  17. ];
  18. public function ownerFeeDetail(): BelongsTo
  19. {
  20. return $this->belongsTo(OwnerFeeDetail::class);
  21. }
  22. public function unit(): BelongsTo
  23. {
  24. return $this->belongsTo(Unit::class);
  25. }
  26. public function getPriceAttribute(): string
  27. {
  28. return $this->unit_price . '/' . $this->unit->name;
  29. }
  30. public function owner(): BelongsTo
  31. {
  32. return $this->belongsTo(Owner::class);
  33. }
  34. public function storeItem(): BelongsTo
  35. {
  36. return $this->belongsTo(StoreItem::class);
  37. }
  38. public function ownerPriceOperation(): BelongsTo
  39. {
  40. return $this->belongsTo(OwnerPriceOperation::class);
  41. }
  42. }