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