public function __construct($user_id = false) { if ($user_id) { $this->user = User::findByAttributes(['user_id' => $user_id]); } else { $this->user = Yii::$app->user->model; } $this->onedriveUserAccess = OnedriveUserAccess::findByAttributes(['user_id' => $this->user->id]); }
public function __construct($initUserInYiiApp = false) { $user = User::findByAttributes(['name' => 'Test', 'last_name' => 'Test']); if (!$user) { $user = new User(); $user->setAttributes(['name' => 'Test', 'last_name' => 'Test']); $user->save(); $user = User::findByAttributes(['name' => 'Test', 'last_name' => 'Test']); } $this->user = $user; if ($initUserInYiiApp) { Yii::$app->user->model = $this->user; } }