From 79dcf2bb3b5c988b88910582a275928f668bdf0f Mon Sep 17 00:00:00 2001 From: arbaz <54329740+arbazbagwan@users.noreply.github.com> Date: Thu, 2 Feb 2023 10:23:54 +0530 Subject: [PATCH] Adding doctors --- app/Http/Controllers/DoctorController.php | 74 +++++ app/Models/Doctor.php | 15 + ...2023_01_31_045108_create_doctors_table.php | 36 +++ resources/views/doctor/form.blade.php | 277 ++++++++++++++++++ resources/views/doctor/list.blade.php | 143 +++++++++ 5 files changed, 545 insertions(+) create mode 100644 app/Http/Controllers/DoctorController.php create mode 100644 app/Models/Doctor.php create mode 100644 database/migrations/2023_01_31_045108_create_doctors_table.php create mode 100644 resources/views/doctor/form.blade.php create mode 100644 resources/views/doctor/list.blade.php diff --git a/app/Http/Controllers/DoctorController.php b/app/Http/Controllers/DoctorController.php new file mode 100644 index 00000000..84477fe2 --- /dev/null +++ b/app/Http/Controllers/DoctorController.php @@ -0,0 +1,74 @@ +middleware('auth'); + $this->_service = 'ums'; + $this->_module = 'contact'; + $this->_viewname = 'doctor'; + $this->_title = 'Doctors'; + $this->_base_url = '/doctor'; + } + + public function list(Request $request) + { + $response = LambdaRequest::signedrequest('get', $this->_service, $this->_module . '/get_my_contacts'); + $fields = $this->get_list_fields(); + return $this->view('list')->with([ + 'title' => $this->_title, + 'fields' => $fields, + 'base_url' => $this->_base_url, + 'items' => $response->data->items, + 'buttons' => $this->get_list_buttons() + ]); + } + + public function createdoctor(Request $request) + { + return Doctor::create($request->only(['msl_code', 'email', 'contact_id', 'name', 'phone']))->id; + } + + protected function get_list_fields() + { + return [ + 'actions' => ['title' => 'Actions', 'buttons' => ['edit', 'delete']], + 'name' => ['title' => 'Name', 'type' => 'text'], + 'msl_code' => ['title' => 'MSL Code', 'type' => 'text'] + ]; + } + + protected function get_form_fields($type, $values) + { + $response = LambdaRequest::signedrequest('get', 'ums', 'contactattribute/get_all'); + // echo '
'; print_r($response); exit;
+
+ $fields = [
+ 'name' => ['title' => 'Name', 'type' => 'text', 'required' => true],
+ 'email' => ['title' => 'Email', 'type' => 'email', 'required' => true],
+ 'phone' => ['title' => 'Phone', 'type' => 'text', 'required' => true],
+ 'msl_code' => ['title' => 'MSL Code', 'type' => 'text'],
+ 'status' => ['title' => 'Status', 'type' => 'select', 'required' => true, 'values' => ['active' => 'Active', 'disabled' => 'Disabled']],
+ ];
+
+ foreach ($response->data->items as $item) {
+ $values = [];
+ if (in_array($item->type, ['select', 'radio', 'checkbox'])) {
+ foreach ($item->options as $op) {
+ $values[$op->value] = $op->display;
+ }
+ }
+ $fields[$item->code] = ['title' => $item->attribute, 'type' => $item->type, 'required' => $item->required == 'yes' ? true : false, 'values' => $values];
+ }
+
+ return $fields;
+ }
+}
diff --git a/app/Models/Doctor.php b/app/Models/Doctor.php
new file mode 100644
index 00000000..561f1eb0
--- /dev/null
+++ b/app/Models/Doctor.php
@@ -0,0 +1,15 @@
+id();
+ $table->string('msl_code');
+ $table->string('email');
+ $table->string('contact_id');
+ $table->string('name');
+ $table->string('phone', 20);
+ $table->timestamps();
+ });
+ }
+
+ /**
+ * Reverse the migrations.
+ *
+ * @return void
+ */
+ public function down()
+ {
+ Schema::dropIfExists('doctors');
+ }
+}
diff --git a/resources/views/doctor/form.blade.php b/resources/views/doctor/form.blade.php
new file mode 100644
index 00000000..0372ed40
--- /dev/null
+++ b/resources/views/doctor/form.blade.php
@@ -0,0 +1,277 @@
+
+
+
+ @include('layouts.shared/title-meta', ['title' => 'Form'])
+ @include('layouts.shared/head-css', ['mode' => $mode ?? '', 'demo' => $demo ?? ''])
+
+
+
+
+
+
+
+
+
+
+ @if (session()->has('message'))
+
+ {{ session()->get('message') }}
+
+ @endif
+
+
+
+
+
+
+
+
+
+
+
+
+@section('script')
+
+
+
+
+
+
+@endsection
diff --git a/resources/views/doctor/list.blade.php b/resources/views/doctor/list.blade.php
new file mode 100644
index 00000000..0df59929
--- /dev/null
+++ b/resources/views/doctor/list.blade.php
@@ -0,0 +1,143 @@
+
+
+
+ @include('layouts.shared/title-meta', ['title' => 'Form'])
+ @include('layouts.shared/head-css', ['mode' => $mode ?? '', 'demo' => $demo ?? ''])
+
+
+
+
+
+
+
+
+
+
+
+ {{ $title }} Listing
+
+
+ @if (isset($buttons))
+ @foreach ($buttons as $button)
+ {{ $button['title'] }}
+ @endforeach
+ @endif
+
+
+
+
+
+
+ @if (session()->has('message'))
+
+ {{ session()->get('message') }}
+
+ @endif
+ @if (session()->has('error'))
+
+ {{ session()->get('error') }}
+
+ @endif
+
+
+
+
+
+
+
+
+
+
+
+
+
+@section('script')
+
+
+
+@endsection