OwnerStoreFeeDetail.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. 'fee',//费用
  16. 'commodity_id',
  17. 'packing_material_fee',//包材费
  18. 'tax_fee',//税费
  19. 'sku',//sku
  20. 'barcode',//条码
  21. 'work_name',//作业名称
  22. 'asn_code',//asn号
  23. ];
  24. public function ownerFeeDetail(): BelongsTo
  25. {
  26. return $this->belongsTo(OwnerFeeDetail::class);
  27. }
  28. public function unit(): BelongsTo
  29. {
  30. return $this->belongsTo(Unit::class);
  31. }
  32. public function getPriceAttribute(): string
  33. {
  34. return $this->unit_price . '/' . $this->unit->name;
  35. }
  36. public function owner(): BelongsTo
  37. {
  38. return $this->belongsTo(Owner::class);
  39. }
  40. public function commodity(): BelongsTo
  41. {
  42. return $this->belongsTo(Commodity::class);
  43. }
  44. /**
  45. * 根据参数条件删除
  46. * @param $data
  47. */
  48. public static function uDelete($data)
  49. {
  50. self::query()
  51. ->where('owner_fee_detail_id', $data['owner_fee_detail_id'])
  52. ->where('unit_id', $data['unit_id'])
  53. ->where('owner_id', $data['owner_id'])
  54. ->where('commodity_id', $data['commodity_id'])
  55. ->where('sku', $data['sku'])
  56. ->where('barcode', $data['barcode'])
  57. ->where('work_name', $data['work_name'])
  58. ->where('asn_code', $data['asn_code'])
  59. ->delete();
  60. }
  61. }