@ -11,8 +11,8 @@ class AppointmentController extends Controller
{
{
public function index(){
public function index(){
$educationAppointments = Appointment::where('service_type', '1')->get();
$educationAppointments = Appointment::where('date', '>=', Carbon::today())->where(' service_type', '1')->get();
$visaAppointments = Appointment::where('service_type', '2')->get();
$visaAppointments = Appointment::where('date', '>=', Carbon::today())->where(' service_type', '2')->get();
// foreach($educationAppointments as $appointment){
// foreach($educationAppointments as $appointment){
// $startTime = Carbon::createFromFormat('H:i', $appointment->start_time);
// $startTime = Carbon::createFromFormat('H:i', $appointment->start_time);
// $date = Carbon::createFromFormat('H:i', $appointment->start_time);
// $date = Carbon::createFromFormat('H:i', $appointment->start_time);
@ -30,6 +30,7 @@ class AppointmentController extends Controller
$month_number = date_parse($date_parts[1])['month'];
$month_number = date_parse($date_parts[1])['month'];
$carbon = Carbon::createFromDate($date_parts[3], $month_number, $date_parts[2]);
$carbon = Carbon::createFromDate($date_parts[3], $month_number, $date_parts[2]);
$date = $carbon->format('Y-m-d');
$date = $carbon->format('Y-m-d');
$type_id = $request->id;
$type_id = $request->id;
$appointments_all = Appointment::whereDate('date',$date)->where(['service_type' => $type_id,'is_booked' => false,'status' => 1])->get();
$appointments_all = Appointment::whereDate('date',$date)->where(['service_type' => $type_id,'is_booked' => false,'status' => 1])->get();
$old_date = Carbon::createFromFormat('Y-m-d', $date);
$old_date = Carbon::createFromFormat('Y-m-d', $date);
@ -37,22 +38,19 @@ class AppointmentController extends Controller
$currentTime = Carbon::now();
$currentTime = Carbon::now();
$appointments = [];
$appointments = [];
foreach ($appointments_all as $appointment) {
foreach ($appointments_all as $appointment) {
$start_time = date("H:i", strtotime($appointment->start_time));
$start_time = explode(" ", $appointment->start_time);
$start_time = $start_time[0];
$appointmentDate = Carbon::createFromFormat('Y-m-d H:i', $appointment->date.' '.$start_time);
$appointmentDate = Carbon::createFromFormat('Y-m-d H:i', $appointment->date.' '.$start_time);
if ($appointmentDate->gt($currentTime)) {
if ($appointmentDate->gt($currentTime)) {
array_push($appointments, $appointment);
array_push($appointments, $appointment);
}
}
}
}
// $users = DB::table('appointments')->whereDate('created_at', '2022-12-01')->get();
// $time = [];
// foreach($appointments as $appointment){
// array_push($time, [$appointment->start_time, $appointment->id]);
// }
// dd($time);
return response()->json(['appointment' => $appointments,'formated_date' => $formated_date]);
return response()->json(['appointment' => $appointments,'formated_date' => $formated_date]);
}
}
public function form_submit(Request $request){
public function form_submit(Request $request){
$request->validate([
$request->validate([
'name' => 'required',
'name' => 'required',
'email' => 'required|email',
'email' => 'required|email',
@ -69,6 +67,8 @@ class AppointmentController extends Controller
$appointment_detail->appointment_id = $appointment_id;
$appointment_detail->appointment_id = $appointment_id;
$email = $request['email'];
$email = $request['email'];
$name = $request['name'];
$name = $request['name'];
$phone = $request['phone'];
if($appointment_detail->save()){
if($appointment_detail->save()){
$date = Carbon::createFromFormat('Y-m-d', $appointment->date);
$date = Carbon::createFromFormat('Y-m-d', $appointment->date);
@ -76,8 +76,9 @@ class AppointmentController extends Controller
$appointment->is_booked = true;
$appointment->is_booked = true;
$appointment->save();
$appointment->save();
$subject = 'Appointment Confirmed';
$subject = 'Appointment Confirmed';
dispatch(function() use ($name,$email,$subject,$formated_date,$appointment) {
dispatch(function() use ($name,$email,$phone,$subject,$formated_date,$appointment) {
\Mail::send('appointment_confirmed', array(
\Mail::send('appointment_confirmed', array(
'full_name' =>$name,
'full_name' =>$name,
@ -89,15 +90,15 @@ class AppointmentController extends Controller
'end_time' => $appointment['end_time'],
'end_time' => $appointment['end_time'],
'phone' =>$appointment[' phone'] ,
'phone' =>$phone,
'subject' =>$subject
'subject' =>$subject
), function($message) use ($subject,$email,$name){
), function($message) use ($subject,$email,$name){
// $subject=($service!= '') ? 'Enquiry for '.$service : 'Contact/Feedback';
// $subject=($service!= '') ? 'Enquiry for '.$service : 'Contact/Feedback';
$message->subject($subject);
$message->subject($subject);
$message->to($email, $name)->subject($subject);
$message->to($email, $name)->subject($subject);
// $message->cc('extratechweb@gmail.com', 'Extratech')->subject($subject);
// $message->cc('extratechweb@gmail.com', 'Extratech')->subject($subject);
// $message->cc('suman@extratechs.com.au', 'Extratech')->subject($subject);
// $message->cc('suman@extratechs.com.au', 'Extratech')->subject($subject);
@ -107,8 +108,5 @@ class AppointmentController extends Controller
return response()->json(['appointment_detail' => $appointment_detail,'appointment' => $appointment,'formated_date' => $formated_date],200);
return response()->json(['appointment_detail' => $appointment_detail,'appointment' => $appointment,'formated_date' => $formated_date],200);
}
}
}
}