Exemplo n.º 1
0
    protected function loadModel(){

        $model = Users::find()->joinWith([
            'company'
        ])->where([
            'users.id' => Auction::$app->user->id
        ])->one();

        if($model === null){
            throw new HttpException(400 , 'Not A Valid Company Admin');
        }

        return $model;
    }
    /**
     * @param $email user email
     * @param $token user - tokrn in url
     *
     * Find And activate user Account
     */
    protected function findModel($email , $token){
        $_model = Users::find()->where('email = :email and password = :pass',[
            'email' => $email,
            ':pass' => $token
        ])->one();

        if(!$_model){
            $this->setUserFlash('Not A valid Link o link Expire');
        }else{
            if($_model->is_active == DatabaseHelper::ACTIVE){
                $this->setUserFlash('User is already Activated');
            }else{
                $_model->is_active = DatabaseHelper::ACTIVE;
                $_model->save();
                $this->setUserFlash('Account Activated');
            }

        }
    }
Exemplo n.º 3
0
    /**
     * Creates data provider instance with search query applied
     *
     * @param array $params
     *
     * @return ActiveDataProvider
     */
    public function search($params)
    {
        $query = Users::find()->joinWith([
            'company'
        ]);

        $dataProvider = new ActiveDataProvider([
            'query' => $query,
            'pagination' => [
                'pageSize' => $this->pageSize
            ]
        ]);

        $this->load($params);

        $dataProvider->pagination->pageSize=$this->pageSize;

        if (!$this->validate()) {
            // uncomment the following line if you do not want to return any records when validation fails
            // $query->where('0=1');
            return $dataProvider;
        }

        $query->where(['!=', 'users.user_role', DatabaseHelper::ADMIN]);

        $query->andFilterWhere([
            'users.is_active' => $this->is_active,
            'users.user_role' => $this->user_role,
        ]);

        $query->andFilterWhere(['like', 'users.name', $this->name])
            ->andFilterWhere(['like', 'users.email', $this->email])
            ->andFilterWhere(['like', 'users.mobile', $this->mobile])
            ->andFilterWhere(['like', 'users.created_at', $this->created_at]);

        return $dataProvider;
    }
    private function SaveUser(){
        $user = new Users();
        $user->setAttributes($this->getAttributes());
        $user->setPassword($this->password);
        $user->user_role=DatabaseHelper::COMPANY_ADMIN;
        $user->is_active=DatabaseHelper::IN_ACTIVE;

        $user->profile_pic = $this->image;

        Auction::info('User Info Saved');
        return $user->save(false) ? $user->id : false;
    }
Exemplo n.º 5
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getUser0()
 {
     return $this->hasOne(Users::className(), ['id' => 'user']);
 }
Exemplo n.º 6
0
 public function getUser(){
     return $this->hasOne(Users::className(),['id' => 'user'])->viaTable(CompanyUsers::tableName(),['company' => 'id']);
 }
Exemplo n.º 7
0
 /**
  * Finds the Users model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Users the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Users::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Exemplo n.º 8
0
    /**
     * Finds the Users model based on its primary key value.
     * If the model is not found, a 404 HTTP exception will be thrown.
     * @param integer $id
     * @return Users the loaded model
     * @throws NotFoundHttpException if the model cannot be found
     */
    protected function findModel($id)
    {
        $model = Users::find()
            ->joinWith(['dealers', 'company'])
            ->where([
                'users.id' => $id
            ])
            ->one();

        if ($model !== null) {
            return $model;
        } else {
            throw new NotFoundHttpException('The requested page does not exist.');
        }
    }
Exemplo n.º 9
0
    /**
     * Finds user by [[username]]
     *
     * @return User|null
     */
    protected function getUser()
    {
        if ($this->_user === null) {
            $this->_user = Users::findByUsername($this->username);
        }

        return $this->_user;
    }
Exemplo n.º 10
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getUsers()
 {
     return $this->hasMany(Users::className(), ['user_role' => 'id']);
 }
Exemplo n.º 11
0
 private function findUser($model,$attribute){
     $this->user =  Users::findByUsername($model->$attribute , false);
     return $this->user;
 }