raw($messageText, function ($message) use ($recipients, $title) { $message->subject($title); $message->to($recipients); }); // return $this->successResponse("mail envoye"); } public function checkPassword($password, $encrypted_password, $salt) { $encrypted_password_to_check = base64_encode(sha1($password . $salt, true) . $salt); return $encrypted_password_to_check == $encrypted_password; } public function hashSSHA($string) { $salt = sha1(rand()); $salt = substr($salt, 0, 10); $encrypted = base64_encode(sha1($string . $salt, true) . $salt); $hash = array("salt" => $salt, "encrypted" => $encrypted); return $hash; } public function getCountryName($id_country){ return Country::findOrFail($id_country)->name; } public function toMoney($amount, $id_country) { $country = Country::findOrFail($id_country); $money = Money::of(round($amount, 0),$country->currency->code); return $money->formatTo('fr_FR'); } public function convertMoney($amount , $init_country , $final_country) { // set to whatever your rates are relative to $baseCurrency = 'USD'; // use your own credentials, or re-use your existing PDO connection $pdo = new PDO('mysql:host=' .env('DB_HOST') . ';dbname=' .env('DB_DATABASE'), env('DB_USERNAME'), env('DB_PASSWORD')); $configuration = new PDOProviderConfiguration(); $configuration->tableName = 'exchange_rate'; $configuration->exchangeRateColumnName = 'exchange_rate'; $configuration->targetCurrencyColumnName = 'target_currency'; $configuration->sourceCurrencyCode = $baseCurrency; // this provider loads exchange rates from your database $provider = new PDOProvider($pdo, $configuration); // this provider calculates exchange rates relative to the base currency $provider = new BaseCurrencyProvider($provider, $baseCurrency); // this currency converter can now handle any currency pair $converter = new CurrencyConverter($provider); $init_country = Country::findOrFail($init_country); $final_country = Country::findOrFail($final_country); $init_money = Money::of(round($amount, 0),$init_country->currency->code);; $final_money = $converter->convert($init_money, $final_country->currency->code, RoundingMode::DOWN); return $final_money->formatTo('fr_FR'); } }