|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109 |
- <?php
-
-
-
- namespace common\models;
-
- use common\helpers\GlobalParam;
- use Yii;
- use common\components\ActiveRecordCommon;
-
-
- class ProductCategory extends ActiveRecordCommon
- {
-
-
- public static function tableName()
- {
- return 'product_category';
- }
-
-
-
- public function rules()
- {
- return [
- [['name'], 'required'],
- [['name'], 'string'],
- [['position'], 'integer'],
- ];
- }
-
-
-
- public function attributeLabels()
- {
- return [
- 'name' => 'Nom',
- 'position' => 'Position'
- ];
- }
-
-
-
- public static function defaultOptionsSearch()
- {
- return [
- 'with' => [],
- 'join_with' => [],
- 'orderby' => '',
- 'attribute_id_producer' => ''
- ];
- }
-
- public static function populateDropdownList()
- {
- $productCategoriesArrayDropdown = ['' => '--'];
- $productCategoriesArray = ProductCategory::find()->where('id_producer = ' . GlobalParam::getCurrentProducerId())->all();
-
- foreach ($productCategoriesArray as $productCategory) {
- $productCategoriesArrayDropdown[$productCategory['id']] = $productCategory['name'];
- }
-
- return $productCategoriesArrayDropdown;
- }
-
- }
|