initial commit
This commit is contained in:
47
app/Listeners/SendAppointmentBookedEmail.php
Normal file
47
app/Listeners/SendAppointmentBookedEmail.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace App\Listeners;
|
||||
|
||||
use App\Events\AppointmentBooked;
|
||||
use App\Models\Setting;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
|
||||
class SendAppointmentBookedEmail implements ShouldQueue
|
||||
{
|
||||
/**
|
||||
* Create the event listener.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the event.
|
||||
*/
|
||||
public function handle(AppointmentBooked $event)
|
||||
{
|
||||
$appointment = $event->appointment;
|
||||
$patient = $appointment->patient;
|
||||
|
||||
$datetimeUtc = $appointment->appointment_date . ' ' . $appointment->appointment_time;
|
||||
$dateTimeUtc = \Carbon\Carbon::createFromFormat('Y-m-d H:i:s', $datetimeUtc, 'UTC');
|
||||
$appointmentTimeZone = new \Carbon\CarbonTimeZone($appointment->timezone);
|
||||
$dateTimeInAppointmentTimeZone = $dateTimeUtc->setTimezone($appointmentTimeZone);
|
||||
$appointment->appointment_date = $appointmentDate = $dateTimeInAppointmentTimeZone->format('Y-m-d');
|
||||
$appointment->appointment_time = $appointmentTime = $dateTimeInAppointmentTimeZone->format('H:i:s');
|
||||
|
||||
$setting = Setting::find(1);
|
||||
|
||||
Mail::send('emails.appointmentBooked', [
|
||||
'patient' => $patient,
|
||||
'appointment' => $appointment,
|
||||
'setting' => $setting
|
||||
], function ($message) use ($patient) {
|
||||
$message->to($patient->email, $patient->first_name)
|
||||
->subject('Appointment Booked.');
|
||||
});
|
||||
}
|
||||
}
|
39
app/Listeners/SendPatientRegisteredEmail.php
Normal file
39
app/Listeners/SendPatientRegisteredEmail.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Listeners;
|
||||
|
||||
use App\Events\PatientRegistered;
|
||||
use App\Models\Setting;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
|
||||
class SendPatientRegisteredEmail implements ShouldQueue
|
||||
{
|
||||
/**
|
||||
* Create the event listener.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the event.
|
||||
*/
|
||||
public function handle(PatientRegistered $event)
|
||||
{
|
||||
$patient = $event->patient;
|
||||
$validatedData = $event->validatedData;
|
||||
|
||||
$setting = Setting::find(1);
|
||||
|
||||
Mail::send('emails.registration', [
|
||||
'patient' => $patient,
|
||||
'setting' => $setting
|
||||
], function ($message) use ($validatedData) {
|
||||
$message->to($validatedData['email'], $validatedData['first_name'])
|
||||
->subject('Account Registered Successfully.');
|
||||
});
|
||||
}
|
||||
}
|
32
app/Listeners/SendPaymentProcessedEmail.php
Normal file
32
app/Listeners/SendPaymentProcessedEmail.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Listeners;
|
||||
|
||||
use App\Events\PaymentProcessed;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
|
||||
class SendPaymentProcessedEmail implements ShouldQueue
|
||||
{
|
||||
/**
|
||||
* Create the event listener.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the event.
|
||||
*/
|
||||
public function handle(PaymentProcessed $event)
|
||||
{
|
||||
$patient = $event->patient;
|
||||
|
||||
Mail::send('emails.process-payment', [], function ($message) use ($patient) {
|
||||
$message->to($patient->email, $patient->first_name)
|
||||
->subject('Payment Processed Successfully.');
|
||||
});
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user