예제 #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');
            }

        }
    }
예제 #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;
    }
예제 #4
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.');
        }
    }