From 77299944dea71323ef390355ec4c23766310d507 Mon Sep 17 00:00:00 2001 From: Mahesh Sharma Date: Wed, 8 Feb 2023 09:46:41 +0545 Subject: [PATCH] apppointment-booking-feature --- .../Admin/AppointmentController.php | 3 + .../Controllers/AppointmentController.php | 41 +++++ config/custom.php | 4 + ..._service_type_id_to_appointments_table.php | 32 ++++ .../views/admin/appointment/create.blade.php | 14 +- .../views/admin/appointment/edit.blade.php | 11 ++ resources/views/appointment.blade.php | 163 ++++++++++++++---- resources/views/blog-detail.blade.php | 2 +- routes/web.php | 9 +- 9 files changed, 241 insertions(+), 38 deletions(-) create mode 100644 app/Http/Controllers/AppointmentController.php create mode 100644 database/migrations/2023_02_07_044441_add_service_type_id_to_appointments_table.php diff --git a/app/Http/Controllers/Admin/AppointmentController.php b/app/Http/Controllers/Admin/AppointmentController.php index cdc10bd..0daadb8 100644 --- a/app/Http/Controllers/Admin/AppointmentController.php +++ b/app/Http/Controllers/Admin/AppointmentController.php @@ -48,6 +48,8 @@ class AppointmentController extends Controller 'end_time' => $request->get('end_time'), 'location' => $request->get('location'), 'description' => $request->get('description'), + 'service_type' => $request->get('service_type'), + ]); $appointment->save(); @@ -78,6 +80,7 @@ class AppointmentController extends Controller $appointment->end_time = $request->get('end_time'); $appointment->location = $request->get('location'); $appointment->description = $request->get('description'); + $appointment->service_type = $request->get('service_type'); $appointment->save(); return redirect($this->redirect)->with('success', 'Appointment has been updated'); diff --git a/app/Http/Controllers/AppointmentController.php b/app/Http/Controllers/AppointmentController.php new file mode 100644 index 0000000..c533a93 --- /dev/null +++ b/app/Http/Controllers/AppointmentController.php @@ -0,0 +1,41 @@ +get(); + $visaAppointments = Appointment::where('service_type', '2')->get(); + // foreach($educationAppointments as $appointment){ + // $startTime = Carbon::createFromFormat('H:i', $appointment->start_time); + // $date = Carbon::createFromFormat('H:i', $appointment->start_time); + // dd($date); + // } + return view('appointment', compact('educationAppointments', 'visaAppointments')); + + } + + public function get_appointment_by_date(Request $request){ + $dateTime = $request->date; + $date_parts = explode(" ", $dateTime); + $month_number = date_parse($date_parts[1])['month']; + $carbon = Carbon::createFromDate($date_parts[3], $month_number, $date_parts[2]); + + $date = $carbon->format('Y-m-d'); + + $appointments = Appointment::whereDate('date',$date)->where('status',1)->get(); + // $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]); + } +} diff --git a/config/custom.php b/config/custom.php index 266b0c7..7f4bc32 100644 --- a/config/custom.php +++ b/config/custom.php @@ -53,6 +53,10 @@ return [ '12'=>'page' ], + 'service_type' => [ + '1' => 'Education', + '2' => 'Visa' + ], 'course_types'=>[ '1' =>'Upcoming Courses', '2' =>'Recommended Courses', diff --git a/database/migrations/2023_02_07_044441_add_service_type_id_to_appointments_table.php b/database/migrations/2023_02_07_044441_add_service_type_id_to_appointments_table.php new file mode 100644 index 0000000..1663a10 --- /dev/null +++ b/database/migrations/2023_02_07_044441_add_service_type_id_to_appointments_table.php @@ -0,0 +1,32 @@ +enum('service_type',[1,2]); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('appointments', function (Blueprint $table) { + // + }); + } +}; diff --git a/resources/views/admin/appointment/create.blade.php b/resources/views/admin/appointment/create.blade.php index 495ae62..c72a4fd 100644 --- a/resources/views/admin/appointment/create.blade.php +++ b/resources/views/admin/appointment/create.blade.php @@ -28,6 +28,17 @@ @include('errors.error') {!! Form::open(['url' => '/admin/appointments', 'class' => 'form-horizontal', 'method'=> 'POST','files' => true,'autocomplete' => 'OFF']) !!}
+
+
+ + +
+
@@ -40,14 +51,12 @@
-
-
@@ -57,7 +66,6 @@ @foreach(config('custom.status') as $in => $val) @endforeach -
diff --git a/resources/views/admin/appointment/edit.blade.php b/resources/views/admin/appointment/edit.blade.php index 301c4e1..4003476 100644 --- a/resources/views/admin/appointment/edit.blade.php +++ b/resources/views/admin/appointment/edit.blade.php @@ -28,6 +28,17 @@ @include('errors.error') {!! Form::open(['url' => '/admin/appointments/'.$appointment->id, 'class' => 'form-horizontal', 'method'=> 'POST','files' => true]) !!}
+
+
+ + +
+
diff --git a/resources/views/appointment.blade.php b/resources/views/appointment.blade.php index 16ababe..d354193 100644 --- a/resources/views/appointment.blade.php +++ b/resources/views/appointment.blade.php @@ -48,60 +48,161 @@
+ + + + + + + + @endsection @section('script') @endsection \ No newline at end of file diff --git a/resources/views/blog-detail.blade.php b/resources/views/blog-detail.blade.php index 00fc014..5128a0e 100644 --- a/resources/views/blog-detail.blade.php +++ b/resources/views/blog-detail.blade.php @@ -15,7 +15,7 @@

{{$blog->title}}

- +
@php $date = Carbon\Carbon::createFromFormat('Y-m-d', $blog->publish_date);@endphp
diff --git a/routes/web.php b/routes/web.php index 903f662..52aa036 100644 --- a/routes/web.php +++ b/routes/web.php @@ -11,6 +11,7 @@ use App\Http\Controllers\RecruitmentController; use App\Http\Controllers\BlogController; use App\Http\Controllers\AboutUsController as FrontendAboutUsController; use App\Http\Controllers\FaqController as FrontendFaqController; +use App\Http\Controllers\AppointmentController as FrontendAppointmentController; use App\Http\Controllers\Admin\ServiceSectionController; use App\Http\Controllers\Admin\AccomodationController; use App\Http\Controllers\Admin\ContactUsController; @@ -68,6 +69,8 @@ Route::get('/visa/{slug}', [VisaController::class,'details']); Route::get('contact', [ContactController::class,'index']); Route::post('contact', [ContactController::class,'post_contact']); Route::get('about', [FrontendAboutUsController::class,'index']); +Route::get('appointment', [FrontendAppointmentController::class,'index']); +Route::post('appointments_by_date', [FrontendAppointmentController::class,'get_appointment_by_date']); // Route::get('/about', function () { // return view('about'); @@ -296,9 +299,9 @@ Route::get('/career_counselling', function () { Route::get('/insurance', function () { return view('insurance'); }); -Route::get('/appointment', function () { - return view('appointment'); -}); +// Route::get('/appointment', function () { +// return view('appointment'); +// }); // Route::get('/visa', function () { // return view('visa'); // });