add changes to account state
This commit is contained in:
@@ -72,6 +72,10 @@ class Account extends \yii\db\ActiveRecord
|
||||
];
|
||||
}
|
||||
|
||||
public function getUserAccountAssignments(){
|
||||
return $this->hasMany(UserAccountAssignment::className(), ['id_account' => 'id_account']);
|
||||
}
|
||||
|
||||
static function statuses() {
|
||||
return [
|
||||
self::STATUS_ACTIVE => Yii::t('common/account', 'Active'),
|
||||
@@ -123,6 +127,22 @@ class Account extends \yii\db\ActiveRecord
|
||||
return $accounts;
|
||||
}
|
||||
|
||||
public static function read($forceIncludeAccount = null){
|
||||
$accounts = null;
|
||||
$query = Account::find();
|
||||
$query->innerJoinWith('userAccountAssignments');
|
||||
$query->andWhere(['user_account_assignment.id_user' => Yii::$app->user->id]);
|
||||
$query->andWhere(['status' => Account::STATUS_ACTIVE]);
|
||||
if ( $forceIncludeAccount == null){
|
||||
$query->andWhere(['status' => Account::STATUS_ACTIVE])->all();
|
||||
}else{
|
||||
$query->andWhere( ['or', ['status' => Account::STATUS_ACTIVE], ['id_account' => $forceIncludeAccount ] ])->all();
|
||||
}
|
||||
|
||||
$accounts = $query->all();
|
||||
return $accounts;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user