add default account to frontend
This commit is contained in:
42
frontend/models/AccountSelect.php
Normal file
42
frontend/models/AccountSelect.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace frontend\models;
|
||||
|
||||
use Yii;
|
||||
use yii\base\Model;
|
||||
use common\models\Account;
|
||||
|
||||
/**
|
||||
* AccountSearch represents the model behind the search form about `common\models\Account`.
|
||||
*/
|
||||
class AccountSelect extends Model
|
||||
{
|
||||
|
||||
public $id_account;
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['id_account', 'type'], 'integer'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function scenarios()
|
||||
{
|
||||
// bypass scenarios() implementation in the parent class
|
||||
return Model::scenarios();
|
||||
}
|
||||
|
||||
public function writeToSession(){
|
||||
$account = Account::findOne($this->id_account);
|
||||
Account::writeDefault($account);
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user