|
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- <?php
-
-
-
- namespace backend\models;
-
- use common\helpers\GlobalParam;
- use Yii;
- use yii\base\Model;
- use common\models\User ;
- use common\models\Producer ;
- use common\models\UserProducer ;
-
-
- class AccessUserProducerForm extends Model
- {
-
- public $id_user ;
-
-
-
- public function rules()
- {
- return [
- [['id_user'], 'required'],
- [['id_user'], 'integer'],
- ];
- }
-
-
-
- public function attributeLabels()
- {
- return [
- 'id_user' => 'Utilisateur',
- ];
- }
-
- public function save()
- {
- $user = User::searchOne([
- 'id' => $this->id_user
- ]) ;
-
- if($user) {
- $user->id_producer = GlobalParam::getCurrentProducerId() ;
- if($user->status != User::STATUS_PRODUCER && $user->status != User::STATUS_ADMIN) {
- $user->status = User::STATUS_PRODUCER ;
- }
- return $user->save();
- }
-
- return false;
- }
-
- }
|