mirror of
				https://github.com/elyby/accounts.git
				synced 2025-05-31 14:11:46 +05:30 
			
		
		
		
	
		
			
				
	
	
		
			26 lines
		
	
	
		
			595 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			26 lines
		
	
	
		
			595 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
<?php
 | 
						|
declare(strict_types=1);
 | 
						|
 | 
						|
namespace common\models;
 | 
						|
 | 
						|
use yii\db\ActiveQuery;
 | 
						|
 | 
						|
/**
 | 
						|
 * @extends \yii\db\ActiveQuery<\common\models\Account>
 | 
						|
 */
 | 
						|
class AccountQuery extends ActiveQuery {
 | 
						|
 | 
						|
    public function excludeDeleted(): self {
 | 
						|
        return $this->andWhere(['NOT', ['status' => Account::STATUS_DELETED]]);
 | 
						|
    }
 | 
						|
 | 
						|
    public function andWhereLogin(string $login): self {
 | 
						|
        return $this->andWhere([$this->getLoginAttribute($login) => $login]);
 | 
						|
    }
 | 
						|
 | 
						|
    private function getLoginAttribute(string $login): string {
 | 
						|
        return strpos($login, '@') ? 'email' : 'username';
 | 
						|
    }
 | 
						|
 | 
						|
}
 |