pimplesushant-pere

RegistrationService.php

Mar 5th, 2019
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 5.17 KB | None | 0 0
  1. <?php
  2.  
  3. namespace App\Services;
  4.  
  5. use App\User;
  6. use Edujugon\PushNotification\PushNotification;
  7. use Illuminate\Mail\Mailer;
  8. use Illuminate\Mail\Message;
  9. use Illuminate\Support\Facades\Log;
  10. use Illuminate\Support\Facades\Config;
  11.  
  12. class RegistrationService
  13. {
  14.  
  15.     protected $mailer, $notify;
  16.  
  17.     public function __construct(Mailer $mailer)
  18.     {
  19.         $this->mailer = $mailer;
  20.     }
  21.  
  22.     public function sendOtp($otp, $mailTo)
  23.     {
  24.         try {
  25.             $textMessage = str_replace('#OTP#', $otp, Config::get('constants.OTP_SMS_TEXT'));
  26.             $data = [
  27.                 'textMessage' => $textMessage
  28.             ];
  29.             $this->mailer->send("emails.otpVerification", $data, function (Message $m) use ($mailTo) {
  30.                 $m->to($mailTo)->subject("OTP Verification");
  31.             });
  32.             return true;
  33.         } catch (\Exception $ex) {
  34.             Log::info($ex->getMessage() . " = " . $ex->getLine());
  35.         }
  36.     }
  37.  
  38.     public function sendForgotPasswordOtp($otp, $mailTo)
  39.     {
  40.         try {
  41.             $textMessage = str_replace('#OTP#', $otp, Config::get('constants.FORGOT_PASSWORD_OTP_TEXT'));
  42.             $data = [
  43.                 'textMessage' => $textMessage
  44.             ];
  45.             $this->mailer->send("emails.otpVerification", $data, function (Message $m) use ($mailTo) {
  46.                 $m->to($mailTo)->subject("Forgot Password");
  47.             });
  48.             return true;
  49.         } catch (\Exception $ex) {
  50.             Log::info($ex->getMessage() . " = " . $ex->getLine());
  51.         }
  52.     }
  53.  
  54.     public function sendClinicCredentials($email, $password)
  55.     {
  56.         try {
  57.             $textMessage = Config::get('constants.CLINIC_REGISTER_MAIL_MESSAGE');
  58.             $data = [
  59.                 'textMessage' => $textMessage,
  60.                 'username' => $email,
  61.                 'password' => $password
  62.             ];
  63.             $this->mailer->send("emails.registerClinic", $data, function (Message $m) use ($email) {
  64.                 $m->to($email)->subject("Clinic Register");
  65.             });
  66.             return true;
  67.         } catch (\Exception $ex) {
  68.             Log::info($ex->getMessage() . " = " . $ex->getLine());
  69.         }
  70.     }
  71.  
  72.     public function sendDoctorCredentials($email, $password)
  73.     {
  74.         try {
  75.             $textMessage = Config::get('constants.DOCTOR_REGISTER_MAIL_MESSAGE');
  76.             $data = [
  77.                 'textMessage' => $textMessage,
  78.                 'username' => $email,
  79.                 'password' => $password
  80.             ];
  81.             $this->mailer->send("emails.registerDoctor", $data, function (Message $m) use ($email) {
  82.                 $m->to($email)->subject("Doctor Register");
  83.             });
  84.             return true;
  85.         } catch (\Exception $ex) {
  86.             Log::info($ex->getMessage() . " = " . $ex->getLine());
  87.         }
  88.     }
  89.  
  90.     public function sendDoctorStatusUpdate($email, $status)
  91.     {
  92.         try {
  93.             $textMessage = "Your Doctor Profile Status Changed to " . $status;
  94.             $data = [
  95.                 'textMessage' => $textMessage,
  96.             ];
  97.             $this->mailer->send("emails.statusDoctor", $data, function (Message $m) use ($email) {
  98.                 $m->to($email)->subject("Doctor Status Change");
  99.             });
  100.             return true;
  101.         } catch (\Exception $ex) {
  102.             Log::info($ex->getMessage() . " = " . $ex->getLine());
  103.         }
  104.     }
  105.  
  106.     public function sendReferralCode($referralCode, $patient_name, $mailTo, $android_link, $ios_link)
  107.     {
  108.         try {
  109.             $data = [
  110.                 'referralCode' => $referralCode,
  111.                 'patient_name' => $patient_name,
  112.                 'android_link' => $android_link,
  113.                 'ios_link' => $ios_link,
  114.             ];
  115.  
  116.             $this->mailer->send("emails.referFriend", $data, function (Message $m) use ($mailTo) {
  117.                 $m->to($mailTo)->subject("Referral code by patient");
  118.             });
  119.  
  120.             return true;
  121.         } catch (\Exception $ex) {
  122.             Log::info($ex->getMessage() . " = " . $ex->getLine());
  123.         }
  124.     }
  125.  
  126.     public function sendCancelAppointment($mailTo, $body)
  127.     {
  128.         try {
  129.             $textMessage = $body;
  130.             $data = [
  131.                 'textMessage' => $textMessage
  132.             ];
  133.  
  134.             $this->mailer->send("emails.cancelAppointment", $data, function (Message $m) use ($mailTo) {
  135.                 $m->to($mailTo)->subject("Appointment Cancelled");
  136.             });
  137.  
  138.             return true;
  139.         } catch (\Exception $ex) {
  140.             Log::info($ex->getMessage() . " = " . $ex->getLine());
  141.         }
  142.     }
  143.  
  144.     public function sendRescheduleAppointment($mailTo, $body)
  145.     {
  146.         try {
  147.             $textMessage = $body;
  148.             $data = [
  149.                 'textMessage' => $textMessage
  150.             ];
  151.  
  152.             $this->mailer->send("emails.cancelAppointment", $data, function (Message $m) use ($mailTo) {
  153.                 $m->to($mailTo)->subject("Appointment Rescheduled");
  154.             });
  155.  
  156.             return true;
  157.         } catch (\Exception $ex) {
  158.             Log::info($ex->getMessage() . " = " . $ex->getLine());
  159.         }
  160.     }
  161. }
Add Comment
Please, Sign In to add comment