OwnerStoreFeeReport.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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 OwnerStoreFeeReport extends Model
  7. {
  8. use ModelLogChanging;
  9. public $fillable = ['owner_bill_report_id', 'owner_price_operation_id', 'owner_id', 'counting_month', 'unit_id', 'unit_price', 'amount', 'fee'];
  10. public $timestamps = false;
  11. // static public $enums = [
  12. // 'type' => [
  13. // '' => 0,
  14. // '退货入库' => 1,
  15. // '新品入库' => 2,
  16. // ],
  17. // ];
  18. //
  19. // function __construct(array $attributes = [])
  20. // {
  21. // foreach (self::$enums as &$enum) {
  22. // $enum = $enum + array_flip($enum);
  23. // }
  24. // parent::__construct($attributes);
  25. // }
  26. //
  27. // public function getTypeAttribute($value)
  28. // {
  29. // if (!$value) return '';
  30. // return self::$enums['type'][$value];
  31. // }
  32. //
  33. // public function setTypeAttribute($value)
  34. // {
  35. // if (!$value) return 0;
  36. // $this->attributes['type'] = self::$enums['type'][$value];
  37. // }
  38. public function ownerBillReport(): BelongsTo
  39. {
  40. return $this->belongsTo(OwnerBillReport::class);
  41. }
  42. public function ownerPriceOperation(): BelongsTo
  43. {
  44. return $this->belongsTo(OwnerPriceOperation::class);
  45. }
  46. public function owner(): BelongsTo
  47. {
  48. return $this->belongsTo(Owner::class);
  49. }
  50. public function unit(): BelongsTo
  51. {
  52. return $this->belongsTo(Unit::class);
  53. }
  54. public function getPriceAttribute(): string
  55. {
  56. return $this->unit_price . '/' . $this->unit->name;
  57. }
  58. }