public function withToken($token) { $client = Client::find()->andWhere(['token' => $token])->limit(1)->one(); return $this->andWhere(['id' => isset($client->user_id) ? $client->user_id : 0]); }