update models + added social network account services
This commit is contained in:
@ -1,9 +1,18 @@
|
||||
<?php
|
||||
namespace Da\User\Query;
|
||||
|
||||
use Da\User\Contracts\AuthClientInterface;
|
||||
use yii\db\ActiveQuery;
|
||||
|
||||
class SocialNetworkAccountQuery extends ActiveQuery
|
||||
{
|
||||
|
||||
public function whereClient(AuthClientInterface $client)
|
||||
{
|
||||
return $this->andWhere(
|
||||
[
|
||||
'provider' => $client->getId(),
|
||||
'client_id' => $client->getUserAttributes()['id']
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,5 +6,20 @@ use yii\db\ActiveQuery;
|
||||
|
||||
class UserQuery extends ActiveQuery
|
||||
{
|
||||
public function whereUsernameOrEmail($usernameOrEmail)
|
||||
{
|
||||
return filter_var($usernameOrEmail, FILTER_VALIDATE_EMAIL)
|
||||
? $this->whereEmail($usernameOrEmail)
|
||||
: $this->whereUsername($usernameOrEmail);
|
||||
}
|
||||
|
||||
public function whereEmail($email)
|
||||
{
|
||||
return $this->andWhere(['email' => $email]);
|
||||
}
|
||||
|
||||
public function whereUsername($username)
|
||||
{
|
||||
return $this->andWhere(['username' => $username]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user