/** * Checks for token duplication in the database,returns true if there is no duplication detected. * * @author EA * @param $token * @param $merchantName * @return bool * @throws RedirectException */ public function validateMerchantToken($token, $merchantName) { $duplicatedTokens = Merchant::all()->where('token', $token); if (!$duplicatedTokens->isEmpty()) { $this->logError('Cannot create merchant[' . $merchantName . '] merchant:Merchant token already exist in database'); throw RedirectException::make('/merchants')->setError('Invalid merchant token '); } return true; }