appointment-update

et#27
Mahesh Sharma 2 years ago
parent c8f0fe2d1e
commit 45d0b8f609
  1. 14
      app/Http/Controllers/AppointmentController.php
  2. 42
      database/seeders/AppointmentTableSeeder.php
  3. BIN
      public/frontend/.DS_Store
  4. 15
      resources/views/appointment.blade.php

@ -29,13 +29,21 @@ class AppointmentController extends Controller
$date_parts = explode(" ", $dateTime); $date_parts = explode(" ", $dateTime);
$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 = 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);
$formated_date = $old_date->format('M d, Y'); $formated_date = $old_date->format('M d, Y');
$currentTime = Carbon::now();
$appointments = [];
foreach ($appointments_all as $appointment) {
$appointmentDate = Carbon::createFromFormat('Y-m-d H:i:s', $appointment->date.' '.$appointment->start_time);
if ($appointmentDate->gt($currentTime) || $appointmentDate > $currentTime) {
array_push($appointments, $appointment);
}
}
// $users = DB::table('appointments')->whereDate('created_at', '2022-12-01')->get(); // $users = DB::table('appointments')->whereDate('created_at', '2022-12-01')->get();
// $time = []; // $time = [];
// foreach($appointments as $appointment){ // foreach($appointments as $appointment){

@ -0,0 +1,42 @@
<?php
namespace Database\Seeders;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
use App\Models\Appointment;
use Carbon\Carbon;
use Carbon\CarbonInterval;
use Illuminate\Support\Facades\DB;
class AppointmentTableSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$startTime = Carbon::parse("09:00:00");
$endTime = Carbon::parse("17:00:00");
for ($i = 0; $i < 7; $i++) {
$date = Carbon::now()->addDays($i);
for ($j = 0; $j <= (($endTime->diffInMinutes($startTime)) / 30); $j++) {
$currentTime = $startTime->copy()->addMinutes(30 * $j);
$currentEndTime = $startTime->copy()->addMinutes(30 * $j + 30);
DB::table('appointments')->insert([
'date' => $date,
'start_time' => $currentTime->format("H:i:s"),
'end_time' => $currentEndTime->format("H:i:s"),
]);
}
}
}
}

Binary file not shown.

@ -135,19 +135,7 @@
function displayCalendar($calender,id){ function displayCalendar($calender,id){
var id = id; var id = id;
$calender.zabuto_calendar({ $calender.zabuto_calendar({
data: [
@foreach($educationAppointments as $appointment)
@php
$date = Carbon\Carbon::createFromFormat('Y-m-d', $appointment->date);
$start_time = Carbon\Carbon::createFromFormat('H:i', $appointment->start_time);
$end_time = Carbon\Carbon::createFromFormat('H:i', $appointment->end_time);
@endphp
{
date: "{{ $date->format('Y-m-d') }}",
content: "{{ $start_time->format('H:i') }} - {{ $end_time->format('H:i') }}"
},
@endforeach
],
classname: 'table clickable table-bordered lightgrey-weekends', classname: 'table clickable table-bordered lightgrey-weekends',
week_starts: 'monday', week_starts: 'monday',
show_days: true, show_days: true,
@ -189,6 +177,7 @@
} }
function dispalyAppointments(appointments,formated_date,id) { function dispalyAppointments(appointments,formated_date,id) {
//display available appointments in timeslot //display available appointments in timeslot
if (appointments.length > 0) { if (appointments.length > 0) {
var timeSlots = ''; var timeSlots = '';

Loading…
Cancel
Save