et#29
Mahesh Sharma 2 years ago
parent 2520f2017b
commit e7b33f2ccc
  1. 32
      app/Http/Controllers/AppointmentController.php
  2. 8
      app/Http/Controllers/HomeController.php
  3. 13
      database/seeders/AppointmentTableSeeder.php
  4. 2
      resources/views/admin/appointment/index.blade.php
  5. 52
      resources/views/appointment.blade.php
  6. 3
      routes/web.php

@ -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);
} }
} }

@ -8,9 +8,17 @@ use App\Models\Testimonial;
use App\Models\NewsAndUpdate; use App\Models\NewsAndUpdate;
use App\Models\Subscription; use App\Models\Subscription;
use App\Models\AboutUs; use App\Models\AboutUs;
use Illuminate\Support\Facades\Artisan;
use Database\Seeders\AppointmentTableSeeder;
class HomeController extends Controller class HomeController extends Controller
{ {
public function runSeeder(){
Artisan::call('db:seed', ['--class' => AppointmentTableSeeder::class]);
}
public function runQueueJobs(){
Artisan::call('queue:listen');
}
public function index(){ public function index(){
$sliders = Slider::where('status',1)->get(); $sliders = Slider::where('status',1)->get();
$testimonials = Testimonial::where('status',1)->get(); $testimonials = Testimonial::where('status',1)->get();

@ -20,16 +20,21 @@ class AppointmentTableSeeder extends Seeder
public function run() public function run()
{ {
$latestAppointment = DB::table('appointments')->latest('date')->first();
$startDate = $latestAppointment ? Carbon::parse($latestAppointment->date)->addDay() : Carbon::now();
$startTime = Carbon::parse("9:00 AM"); $startTime = Carbon::parse("9:00 AM");
$endTime = Carbon::parse("5:00 PM"); $endTime = Carbon::parse("5:00 PM");
foreach(config('custom.service_type') as $key => $value){ foreach(config('custom.service_type') as $key => $value){
for ($i = 0; $i < 7; $i++) { for ($i = 0; $i < 7; $i++) {
$date = Carbon::now()->addDays($i); $date = $startDate->copy()->addDays($i);
for ($j = 0; $j <= ((($endTime->diffInMinutes($startTime)) / 30)-1); $j++) { for ($j = 0; $j <= ((($endTime->diffInMinutes($startTime)) / 30)-1); $j++) {
$currentTime = $startTime->copy()->addMinutes(30 * $j); $currentTime = $startTime->copy()->addMinutes(30 * $j);
$currentEndTime = $startTime->copy()->addMinutes(30 * $j + 30); $currentEndTime = $startTime->copy()->addMinutes(30 * $j + 30);
DB::table('appointments')->insert([ DB::table('appointments')->insert([
'date' => $date, 'date' => $date,
'start_time' => $currentTime->format("H:i A"), 'start_time' => $currentTime->format("H:i A"),
@ -39,6 +44,6 @@ class AppointmentTableSeeder extends Seeder
} }
} }
} }
} }
} }

@ -74,9 +74,11 @@
<td class="text-center">{{$setting->is_booked ? 'Booked' : 'Not Booked'}}</td> <td class="text-center">{{$setting->is_booked ? 'Booked' : 'Not Booked'}}</td>
<td class="d-flex justify-content-center action-icons"> <td class="d-flex justify-content-center action-icons">
@if($setting->appointment_booking_detail()->count() > 0)
<a href="{{url('admin/appointments/'.$setting->id.'/view')}}" class="btn btn-sm" data-bs-toggle="tooltip" data-bs-placement="top" title="view"> <a href="{{url('admin/appointments/'.$setting->id.'/view')}}" class="btn btn-sm" data-bs-toggle="tooltip" data-bs-placement="top" title="view">
<i class="fa-solid fa-eye"></i> <i class="fa-solid fa-eye"></i>
</a> </a>
@endif
<a href="{{url('admin/appointments/'.$setting->id.'/edit')}}" class="btn btn-sm" data-bs-toggle="tooltip" data-bs-placement="top" title="edit"> <a href="{{url('admin/appointments/'.$setting->id.'/edit')}}" class="btn btn-sm" data-bs-toggle="tooltip" data-bs-placement="top" title="edit">
<i class="fas fa-pencil-alt"></i> <i class="fas fa-pencil-alt"></i>
</a> </a>

@ -65,12 +65,12 @@
<div class="modal-dialog" role="document"> <div class="modal-dialog" role="document">
<div class="modal-content"> <div class="modal-content">
<div class="modal-header"> <div class="modal-header">
<h3 class="modal-title" id="appointmentModalLabel">Book Appointment</h3> <h3 class="modal-title" id="appointmentModalLabel">Book Appointment</span></h3>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button> <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div> </div>
<div class="modal-body"> <div class="modal-body">
<div class="book-modal-info"> <div class="book-modal-info">
<p>Book your appointment for &nbsp;<span id = "booking_date"></span><span class="time" id = "start_time"></span> to <span id = "end_time"></span></p> <p>You are about to book your appointment for <span id = "booking_service"></span> at date &nbsp;<span id = "booking_date"></span><span class="time" id = "start_time"></span> to <span id = "end_time"></span></p>
</div> </div>
<!-- Form with the fields name, email, phone, and notes --> <!-- Form with the fields name, email, phone, and notes -->
<form id ="appointment-form"> <form id ="appointment-form">
@ -135,25 +135,29 @@
function displayCalendar($calender,id){ function displayCalendar($calender,id){
var id = id; var id = id;
var now = new Date(); var now = new Date();
var appointments_list = id == 1 ? {!! json_encode($educationAppointments) !!} : {!! json_encode($visaAppointments) !!};
var events = [];
appointments_list.forEach(function(list) {
events.push({
date: list.date,
classname: "clickable event-clickable"
});
});
$calender.zabuto_calendar({ $calender.zabuto_calendar({
classname: 'table event-colourful table-bordered lightgrey-weekends', classname: 'table event-colourful table-bordered lightgrey-weekends',
week_starts: 'monday', week_starts: 'monday',
show_days: true, show_days: true,
cell_border: true, cell_border: true,
show_days: true, weekstartson: 0,
weekstartson: 0, navigation_markup: {
navigation_markup: { prev: '<i class="fas fa-chevron-circle-left"></i>',
prev: '<i class="fas fa-chevron-circle-left"></i>', next: '<i class="fas fa-chevron-circle-right"></i>'
next: '<i class="fas fa-chevron-circle-right"></i>' },
},
events:[ events:events
@foreach($educationAppointments as $appointment)
{
date: "{{ $appointment->date }}",
"classname": "clickable event-clickable"
},
@endforeach
]
}); });
@ -213,7 +217,13 @@
var startTime = $(this).data("start-time"); var startTime = $(this).data("start-time");
var endTime = $(this).data("end-time"); var endTime = $(this).data("end-time");
$('#appointment-form input[name="appointment_id"]').val(appointmentId); $('#appointment-form input[name="appointment_id"]').val(appointmentId);
$('#booking_date').html(formated_date); $('#booking_date').html('<b>'+formated_date+'</b>');
if(id == 1){
$('#booking_service').html('<b>Education Service</b>');
}
if(id == 2){
$('#booking_service').html('<b>Migration/Visa Service</b>');
}
$('#start_time').html('&nbsp;<b>('+startTime+'</b>'); $('#start_time').html('&nbsp;<b>('+startTime+'</b>');
$('#end_time').html('<b>'+endTime+')</b>'); $('#end_time').html('<b>'+endTime+')</b>');
$("#modal").modal("show"); $("#modal").modal("show");

@ -53,7 +53,8 @@ use App\Http\Controllers\Admin\AppointmentController;
| contains the "web" middleware group. Now create something great! | contains the "web" middleware group. Now create something great!
| |
*/ */
Route::get('/mycron', [HomeController::class,'runQueueJobs']);
Route::get('/seed', [HomeController::class,'runSeeder']);
Route::get('/', [HomeController::class,'index'])->name('home.index'); Route::get('/', [HomeController::class,'index'])->name('home.index');
Route::get('login', [HomeAdminController::class,'getLogin'])->name('login'); Route::get('login', [HomeAdminController::class,'getLogin'])->name('login');

Loading…
Cancel
Save