|
Server : Apache/2.4.41 (Ubuntu) System : Linux vmi1525618.contaboserver.net 5.4.0-105-generic #119-Ubuntu SMP Mon Mar 7 18:49:24 UTC 2022 x86_64 User : www-data ( 33) PHP Version : 8.2.12 Disable Function : NONE Directory : /var/www/account.appointkrypt.com/app/Listeners/ |
Upload File : |
<?php
namespace App\Listeners;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Queue\InteractsWithQueue;
use App\Models\Business;
use App\Models\Appointment;
use App\Models\User;
use App\Models\AppointmentPayment;
class AppointmentPaymentLis
{
/**
* Create the event listener.
*/
public function __construct()
{
//
}
/**
* Handle the event.
*/
public function handle($event)
{
$data = $event->data;
$slug = $event->payment;
$type = $event->type;
$business = Business::where('slug', $slug)->first();
if ($data) {
$user = User::create([
'name' => $data['user_name'],
'email' => $data['email'],
'mobile_no' => $data['contact'],
'email_verified_at' => date('Y-m-d h:i:s'),
'password' => !empty($data['password']) ? Hash::make($data['password']) : null,
'avatar' => 'uploads/users-avatar/avatar.png',
'type' => 'customer',
'lang' => 'en',
'business_id' => $business->id,
'created_by' => $business->created_by,
]);
$Appointment = Appointment::create([
'customer_id' => $data['customer'] ?? null,
'location_id' => $data['location'],
'service_id' => $data['service'],
'staff_id' => $data['staff'],
'date' => $data['appointment_date'],
'time' => $data['duration'],
'notes' => $data['notes'] ?? '',
'payment_type' => $data['payment_type'],
'appointment_status' => 'Pending',
'business_id' => $business->id,
'created_by' => $business->created_by,
]);
}
$payment = AppointmentPayment::create([
'appointment_id' => $Appointment->id,
'payment_type' => $data['payment_type'],
'amount' => $data['price'],
'payment_date' => now(),
'business_id' => $business->id,
'created_by' => $business->created_by,
]);
return $Appointment->id;
}
}