/** * @param $login - user login * @param bool $runSave - save new user after creation new * @return Customer - existing user or new. */ public static function findByLoginOrCreateNew($login, $runSave = false) { if ($user = static::findByLogin($login)) { return $user; } $user = new Customer($login); if ($runSave) { $user->save(); } return $user; }
/** * Configures EWallet with customer who has login - $login and password from DB * * @param $login - payture login * @return Customer - customer object */ private function configureEWalletWithUser($login) { $customer = Customer::findByLoginOrCreateNew($login, true); PaytureEWalletConfiguration::setVWUserLogin($customer->login); PaytureEWalletConfiguration::setVWUserPassword($customer->password); return $customer; }
public function getCustomer() { return $this->hasOne(Customer::className(), ['id' => 'payture_customer_id']); }