ProductItem.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. <?php
  2. namespace App\MicroApi\Items;
  3. class ProductItem
  4. {
  5. public $id;
  6. public $brand_id;
  7. public $sku;
  8. public $name;
  9. public $slug;
  10. public $status;
  11. public $description;
  12. public $cover;
  13. public $quantity;
  14. public $price;
  15. public $sale_price;
  16. public $length;
  17. public $width;
  18. public $height;
  19. public $weight;
  20. public $distance_unit;
  21. public $mass_unit;
  22. public $created_at;
  23. public $updated_at;
  24. public $brand;
  25. public $categories;
  26. public $images;
  27. public $attributes;
  28. public function fillAttributes($data)
  29. {
  30. if (is_object($data)) {
  31. $data = get_object_vars($data);
  32. }
  33. foreach ($data as $key => $value) {
  34. switch (strtolower($key)) {
  35. case 'id':
  36. $this->id = $value;
  37. break;
  38. case 'brand_id':
  39. $this->brand_id = $value;
  40. break;
  41. case 'sku':
  42. $this->sku = $value;
  43. break;
  44. case 'name':
  45. $this->name = $value;
  46. break;
  47. case 'slug':
  48. $this->slug = $value;
  49. break;
  50. case 'status':
  51. $this->status = $value;
  52. break;
  53. case 'description':
  54. $this->description = $value;
  55. break;
  56. case 'cover':
  57. $this->cover = $value;
  58. break;
  59. case 'quantity':
  60. $this->quantity = $value;
  61. break;
  62. case 'price':
  63. $this->price = $value;
  64. break;
  65. case 'sale_price':
  66. $this->sale_price = $value;
  67. break;
  68. case 'length':
  69. $this->length = $value;
  70. break;
  71. case 'width':
  72. $this->width = $value;
  73. break;
  74. case 'height':
  75. $this->height = $value;
  76. break;
  77. case 'weight':
  78. $this->weight = $value;
  79. break;
  80. case 'distance_unit':
  81. $this->distance_unit = $value;
  82. break;
  83. case 'mass_unit':
  84. $this->mass_unit = $value;
  85. break;
  86. case 'created_at':
  87. $this->created_at = $value;
  88. break;
  89. case 'updated_at':
  90. $this->updated_at = $value;
  91. break;
  92. case 'brand':
  93. $this->brand = $value;
  94. break;
  95. case 'images':
  96. $this->images = $value;
  97. break;
  98. case 'categories':
  99. $this->categories = $value;
  100. break;
  101. case 'attributes':
  102. $this->attributes = $value;
  103. break;
  104. default:
  105. break;
  106. }
  107. }
  108. return $this;
  109. }
  110. }