You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

пре 6 месеци
пре 6 месеци
пре 6 месеци
пре 6 месеци
пре 6 месеци
пре 6 месеци
пре 6 месеци
пре 6 месеци
пре 6 месеци
пре 6 месеци
пре 6 месеци
пре 6 месеци
пре 6 месеци
пре 6 месеци
пре 6 месеци
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. <?php
  2. namespace domain\Product\Rotating;
  3. use common\components\ActiveRecordCommon;
  4. use common\components\Date;
  5. use domain\Distribution\DistributionRotating\DistributionRotating;
  6. use domain\Producer\Producer\Producer;
  7. use domain\Product\RotatingProduct\RotatingProduct;
  8. use yii\db\ActiveQuery;
  9. class Rotating extends ActiveRecordCommon
  10. {
  11. // Produits sélectionnés dans le formulaire
  12. public $selected_products_ids;
  13. public static function tableName()
  14. {
  15. return 'rotating';
  16. }
  17. public function rules()
  18. {
  19. return [
  20. [['id_producer', 'name', 'day'], 'required'],
  21. [['name'], 'string', 'max' => 255],
  22. [['id_producer', 'day', 'status'], 'integer'],
  23. [['selected_products_ids'], 'safe'],
  24. ];
  25. }
  26. public function attributeLabels()
  27. {
  28. return [
  29. 'id' => 'ID',
  30. 'id_producer' => 'Producteur',
  31. 'name' => 'Nom',
  32. 'day' => 'Jour',
  33. 'status' => 'Statut',
  34. ];
  35. }
  36. /* Getters / Setters */
  37. public function getId(): ?int
  38. {
  39. return $this->id;
  40. }
  41. public function getProducer(): Producer
  42. {
  43. return $this->producerRelation;
  44. }
  45. public function setProducer(Producer $producer): self
  46. {
  47. $this->populateFieldObject('id_producer', 'producerRelation', $producer);
  48. return $this;
  49. }
  50. public function getName(): string
  51. {
  52. return $this->name;
  53. }
  54. public function setName(string $name): self
  55. {
  56. $this->name = $name;
  57. return $this;
  58. }
  59. public function getDay(): int
  60. {
  61. return $this->day;
  62. }
  63. public function setDay(int $day): self
  64. {
  65. $this->day = $day;
  66. return $this;
  67. }
  68. public function getStatus(): int
  69. {
  70. return $this->status;
  71. }
  72. public function setStatus(int $status): self
  73. {
  74. $this->status = $status;
  75. return $this;
  76. }
  77. public function getSelectedProductsIds()
  78. {
  79. return $this->selected_products_ids;
  80. }
  81. public function setSelectedProductsIds(array $selectedProductsIdsArray): self
  82. {
  83. $this->selected_products_ids = $selectedProductsIdsArray;
  84. return $this;
  85. }
  86. public function getDistributionRotatings(): array
  87. {
  88. return $this->distributionRotatingsRelation;
  89. }
  90. public function getRotatingProducts(): array
  91. {
  92. return $this->rotatingProductsRelation;
  93. }
  94. /* Relations */
  95. public function getProducerRelation(): ActiveQuery
  96. {
  97. return $this->hasOne(Producer::class, ['id' => 'id_producer']);
  98. }
  99. public function getRotatingProductsRelation()
  100. {
  101. return $this->hasMany(RotatingProduct::class, ['id_rotating' => 'id']);
  102. }
  103. public function getDistributionRotatingsRelation()
  104. {
  105. return $this->hasMany(DistributionRotating::class, ['id_rotating' => 'id']);
  106. }
  107. /* Méthodes */
  108. public function getDayAsString(string $lang = 'fr'): string
  109. {
  110. return Date::getDayOfWeekStringByNumber($this->getDay(), $lang);
  111. }
  112. }