public function fbAuth() { $client_user = ClientUsers::findByEmail($this->email); if ($client_user instanceof ClientUsers) { $client_user->auth_key; } else { $client_user = new ClientUsers(); $client_user->attributes = $this->attributes; } $client_user->save(); $this->auth_key = $client_user->auth_key; return true; }
public function beforeAction($action) { $auth_key = Yii::$app->request->getQueryParam('auth_key'); $client_user = null; if ($auth_key !== null) { $client_user = ClientUsers::findOne(['auth_key' => $auth_key]); } if (!$client_user instanceof ClientUsers) { throw new HttpException(403, 'You are not allowed to perform this action'); } else { $action->controller->client_user = $client_user; return true; } }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params = []) { $query = ClientUsers::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['id' => $this->id]); $query->andFilterWhere(['like', 'email', $this->email])->andFilterWhere(['like', 'password', $this->password])->andFilterWhere(['like', 'auth_key', $this->auth_key]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params = []) { $query = Info::find(); $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => self::ITEMS_PER_PAGE], 'sort' => ['attributes' => ['key' => ['asc' => ['message' => SORT_ASC], 'desc' => ['message' => SORT_DESC]], 'value' => ['asc' => ['value' => SORT_ASC], 'desc' => ['value' => SORT_DESC]], 'clientEmail' => ['asc' => [ClientUsers::tableName() . '.email' => SORT_ASC], 'desc' => [ClientUsers::tableName() . '.email' => SORT_DESC]]]]]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->joinWith(['client' => function (ActiveQuery $query) { $query->andFilterWhere(['like', ClientUsers::tableName() . '.email', $this->clientEmail]); }]); $query->andFilterWhere(['like', 'key', $this->key])->andFilterWhere(['like', 'value', $this->value]); return $dataProvider; }
public function clientBeacons($client_user_id = null) { $query = Beacons::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); if (!$this->validate()) { // uncomment the following line if you do not want to any records when validation fails // $query->where('0=1'); return $dataProvider; } if ($client_user_id !== null) { $user = ClientUsers::findOne(['id' => $client_user_id]); $query->joinWith(['clientBeacons' => function (ActiveQuery $query) use($user) { $query->andFilterWhere(['client_id' => $user->id]); }]); } $query->andFilterWhere(['id' => $this->id, 'minor' => $this->minor, 'major' => $this->major]); $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'uuid', $this->uuid]); return $dataProvider; }
public function actionFbAuth() { $model = new ClientUsers(); if ($model->load(Yii::$app->request->post())) { if ($model->fbAuth()) { return ['auth_key' => $model->auth_key]; } } throw new HttpException(400, 'Your credentials are invalid ' . Helper::recursive_implode($model->errors, ',', false, false)); }
public function getClient() { return $this->hasOne(ClientUsers::className(), ['id' => 'client_id']); }
public function getClientUsers() { return $this->hasMany(ClientUsers::className(), ['id' => 'client_id'])->via('clientBindings'); }
/** * Provides json response for select2 plugin */ public function actionGetSelectionById() { self::selectionById(ClientUsers::className(), 'name'); }