mirror of
https://github.com/elyby/accounts.git
synced 2025-05-31 14:11:46 +05:30
Implemented account deletion. Not all cases covered with tests [skip ci]
This commit is contained in:
@@ -1,29 +1,32 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace common\models;
|
||||
|
||||
use yii\behaviors\TimestampBehavior;
|
||||
use yii\db\ActiveQuery;
|
||||
use yii\db\ActiveRecord;
|
||||
|
||||
/**
|
||||
* Fields:
|
||||
* @property integer $id
|
||||
* @property string $username
|
||||
* @property integer $account_id
|
||||
* @property integer $applied_in
|
||||
* @property int $id
|
||||
* @property string $username
|
||||
* @property int|null $account_id
|
||||
* @property int $applied_in
|
||||
*
|
||||
* Relations:
|
||||
* @property Account $account
|
||||
* @property-read Account $account
|
||||
*
|
||||
* Behaviors:
|
||||
* @mixin TimestampBehavior
|
||||
*/
|
||||
class UsernameHistory extends ActiveRecord {
|
||||
|
||||
public static function tableName() {
|
||||
return '{{%usernames_history}}';
|
||||
public static function tableName(): string {
|
||||
return 'usernames_history';
|
||||
}
|
||||
|
||||
public function behaviors() {
|
||||
public function behaviors(): array {
|
||||
return [
|
||||
[
|
||||
'class' => TimestampBehavior::class,
|
||||
@@ -33,19 +36,17 @@ class UsernameHistory extends ActiveRecord {
|
||||
];
|
||||
}
|
||||
|
||||
public function rules() {
|
||||
return [];
|
||||
}
|
||||
|
||||
public function getAccount() {
|
||||
public function getAccount(): ActiveQuery {
|
||||
return $this->hasOne(Account::class, ['id' => 'account_id']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Find the username after the current of the account.
|
||||
*
|
||||
* @param int $afterTime
|
||||
* @return UsernameHistory|null
|
||||
*/
|
||||
public function findNext(int $afterTime = null): ?self {
|
||||
public function findNextOwnerUsername(int $afterTime = null): ?self {
|
||||
return self::find()
|
||||
->andWhere(['account_id' => $this->account_id])
|
||||
->andWhere(['>', 'applied_in', $afterTime ?: $this->applied_in])
|
||||
|
||||
Reference in New Issue
Block a user