From 41f88d9e24bcf600bd0239e8af4e53fee991bd45 Mon Sep 17 00:00:00 2001 From: Mahesh Sharma Date: Tue, 7 Feb 2023 09:49:21 +0545 Subject: [PATCH] appointment --- .../Admin/AppointmentController.php | 94 ++++++++ app/Models/Appointment.php | 13 ++ ...02_06_080253_create_appointments_table.php | 37 ++++ .../views/admin/applicant/create.blade.php | 157 -------------- .../views/admin/applicant/edit.blade.php | 203 ------------------ .../views/admin/appointment/create.blade.php | 104 +++++++++ .../views/admin/appointment/edit.blade.php | 127 +++++++++++ .../index.blade.php | 39 ++-- .../{applicant => appointment}/show.blade.php | 0 .../views/admin/layouts/menubar.blade.php | 8 + routes/web.php | 15 +- 11 files changed, 410 insertions(+), 387 deletions(-) create mode 100644 app/Http/Controllers/Admin/AppointmentController.php create mode 100644 app/Models/Appointment.php create mode 100644 database/migrations/2023_02_06_080253_create_appointments_table.php delete mode 100644 resources/views/admin/applicant/create.blade.php delete mode 100644 resources/views/admin/applicant/edit.blade.php create mode 100644 resources/views/admin/appointment/create.blade.php create mode 100644 resources/views/admin/appointment/edit.blade.php rename resources/views/admin/{applicant => appointment}/index.blade.php (81%) rename resources/views/admin/{applicant => appointment}/show.blade.php (100%) diff --git a/app/Http/Controllers/Admin/AppointmentController.php b/app/Http/Controllers/Admin/AppointmentController.php new file mode 100644 index 0000000..cdc10bd --- /dev/null +++ b/app/Http/Controllers/Admin/AppointmentController.php @@ -0,0 +1,94 @@ +whereDate('date',$key); + } + if(\request('status')){ + $key = \request('status'); + $appointments = $appointments->where('status',$key); + } + $appointments = $appointments->paginate(config('custom.per_page')); + return view($this->view.'index',compact('appointments')); + } + + public function create() + { + return view($this->view.'create'); + } + + public function store(Request $request) + { + $request->validate([ + 'date' => 'required|date', + 'start_time' => 'required|date_format:H:i', + 'end_time' => 'required|date_format:H:i', + // 'location' => 'required|max:255', + // 'description' => 'required', + ]); + + $appointment = new Appointment([ + 'date' => $request->get('date'), + 'start_time' => $request->get('start_time'), + 'end_time' => $request->get('end_time'), + 'location' => $request->get('location'), + 'description' => $request->get('description'), + ]); + + $appointment->save(); + + return redirect($this->redirect)->with('success', 'Appointment has been added'); + } + + public function edit($id) + { + $appointment = Appointment::find($id); + + return view($this->view.'edit', compact('appointment')); + } + + public function update(Request $request, $id) + { + $request->validate([ + 'date' => 'required|date', + 'start_time' => 'required|date_format:H:i', + 'end_time' => 'required|date_format:H:i', + // 'location' => 'required|max:255', + // 'description' => 'required', + ]); + + $appointment = Appointment::find($id); + $appointment->date = $request->get('date'); + $appointment->start_time = $request->get('start_time'); + $appointment->end_time = $request->get('end_time'); + $appointment->location = $request->get('location'); + $appointment->description = $request->get('description'); + $appointment->save(); + + return redirect($this->redirect)->with('success', 'Appointment has been updated'); + } + + public function destroy($id) + { + $appointment = Appointment::find($id); + $appointment->delete(); + + return redirect($this->redirect)->with('success', 'Appointment has been deleted'); + } +} + diff --git a/app/Models/Appointment.php b/app/Models/Appointment.php new file mode 100644 index 0000000..408a7c5 --- /dev/null +++ b/app/Models/Appointment.php @@ -0,0 +1,13 @@ +id(); + $table->date('date'); + $table->string('start_time'); + $table->string('end_time'); + $table->string('location')->nullable(); + $table->string('description')->nullable(); + $table->enum('status',[1,2]); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('appointments'); + } +}; diff --git a/resources/views/admin/applicant/create.blade.php b/resources/views/admin/applicant/create.blade.php deleted file mode 100644 index 4614e64..0000000 --- a/resources/views/admin/applicant/create.blade.php +++ /dev/null @@ -1,157 +0,0 @@ -@extends('admin.layouts.app') -@section('content') - -
- -
-
-
-
-

Career

-
-
-
-
- - -
-
- -
-
-

Create Career

- List - -
-
- @include('success.success') - @include('errors.error') - {!! Form::open(['url' => '/admin/careers', 'class' => 'form-horizontal', 'method'=> 'POST','files' => true,'autocomplete' => 'OFF']) !!} -
- -
-
- - -
-
-
-
- - -
-
-
-
- - -
-
-
-
- - -
-
- -
-
- - -
-
- -
-
- - -
-
-
-
- - -{{-- --}} -
-
-
-
- - -
-
- -
- -
-
-
-
-
- - -
-
-
- -
- -
- -
-
-
-
-
- - -
-
-
- -
-
- -
-
- {!! Form::close() !!} -
-
-
-
-
-@endsection -@section('script') - - - -@endsection - diff --git a/resources/views/admin/applicant/edit.blade.php b/resources/views/admin/applicant/edit.blade.php deleted file mode 100644 index f92bcbc..0000000 --- a/resources/views/admin/applicant/edit.blade.php +++ /dev/null @@ -1,203 +0,0 @@ -@extends('admin.layouts.app') -@section('content') - -
- -
-
-
-
-

Career

-
-
-
-
- - -
-
- -
-
-

Edit Career

- Back - -
-
- @include('success.success') - @include('errors.error') - {!! Form::open(['url' => '/admin/careers/'.$about_us->id, 'class' => 'form-horizontal', 'method'=> 'POST','files' => true]) !!} -
- -
-
- - -
- - - - - -
-
- - - - -
-
- - -
-
-
-
- - -
-
-
-
- - -
-
- - -
-
- - -
-
- -
-
- - -
-
-
-
- - -
-
-
-
- - -
-
- - - - - - - -
- - @if($about_us->career_points->count() > 0) -
-
-
-
-
- - - -
- @foreach($about_us->career_points as $point) -
-
-
- -
- @endforeach - -
- -
-
-
-
-
- - -
-
-
- @endif -
-
- -
-
- {!! Form::close() !!} -
-
-
-
-
-@endsection -@section('script') - -@endsection - diff --git a/resources/views/admin/appointment/create.blade.php b/resources/views/admin/appointment/create.blade.php new file mode 100644 index 0000000..495ae62 --- /dev/null +++ b/resources/views/admin/appointment/create.blade.php @@ -0,0 +1,104 @@ +@extends('admin.layouts.app') +@section('content') + +
+ +
+
+
+
+

Appointment

+
+
+
+
+ + +
+
+ +
+
+

Create Appointment

+ List + +
+
+ @include('success.success') + @include('errors.error') + {!! Form::open(['url' => '/admin/appointments', 'class' => 'form-horizontal', 'method'=> 'POST','files' => true,'autocomplete' => 'OFF']) !!} +
+
+
+ + +
+
+
+
+ + +
+
+ +
+
+ + +
+
+ + +
+
+ + +
+
+
+ +
+
+ +
+
+ {!! Form::close() !!} +
+
+
+
+
+@endsection +@section('script') + + + +@endsection + diff --git a/resources/views/admin/appointment/edit.blade.php b/resources/views/admin/appointment/edit.blade.php new file mode 100644 index 0000000..301c4e1 --- /dev/null +++ b/resources/views/admin/appointment/edit.blade.php @@ -0,0 +1,127 @@ +@extends('admin.layouts.app') +@section('content') + +
+ +
+
+
+
+

Appointment

+
+
+
+
+ + +
+
+ +
+
+

Edit Appointment

+ List + +
+
+ @include('success.success') + @include('errors.error') + {!! Form::open(['url' => '/admin/appointments/'.$appointment->id, 'class' => 'form-horizontal', 'method'=> 'POST','files' => true]) !!} +
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+ +
+ + +
+
+ +
+
+ {!! Form::close() !!} +
+
+
+
+
+@endsection +@section('script') + +@endsection + diff --git a/resources/views/admin/applicant/index.blade.php b/resources/views/admin/appointment/index.blade.php similarity index 81% rename from resources/views/admin/applicant/index.blade.php rename to resources/views/admin/appointment/index.blade.php index 29686aa..3e324e4 100644 --- a/resources/views/admin/applicant/index.blade.php +++ b/resources/views/admin/appointment/index.blade.php @@ -21,8 +21,10 @@
-

Applicants

- +

Appointments

+
+ Create +
@@ -33,7 +35,7 @@
@@ -53,31 +55,28 @@ S.N. - Applicants Name - Mobile - Email + Date + Start Time + End Time Action - @foreach($settings as $setting) + @foreach($appointments as $setting) {{$loop->iteration}} - {{$setting->name}} - {{$setting->phone}} - {{$setting->email}} + {{$setting->date}} + {{$setting->start_time}} + {{$setting->end_time}} - + - - + + + + + @@ -86,7 +85,7 @@
- {!! $settings->links() !!} + {!! $appointments->links() !!}
diff --git a/resources/views/admin/applicant/show.blade.php b/resources/views/admin/appointment/show.blade.php similarity index 100% rename from resources/views/admin/applicant/show.blade.php rename to resources/views/admin/appointment/show.blade.php diff --git a/resources/views/admin/layouts/menubar.blade.php b/resources/views/admin/layouts/menubar.blade.php index 017ecc0..b084f66 100644 --- a/resources/views/admin/layouts/menubar.blade.php +++ b/resources/views/admin/layouts/menubar.blade.php @@ -131,6 +131,14 @@

+