appointment-seeder-overall-completed

et#27
Mahesh Sharma 2 years ago
parent 45d0b8f609
commit 98fb64971a
  1. 10
      app/Http/Controllers/Admin/AppointmentController.php
  2. 7
      app/Http/Controllers/AppointmentController.php
  3. 16
      database/seeders/AppointmentTableSeeder.php
  4. 6
      resources/views/admin/appointment/edit.blade.php
  5. 21
      resources/views/appointment.blade.php

@ -23,7 +23,7 @@ class AppointmentController extends Controller
$key = \request('status');
$appointments = $appointments->where('status',$key);
}
$appointments = $appointments->paginate(config('custom.per_page'));
$appointments = $appointments->paginate(20);
return view($this->view.'index',compact('appointments'));
}
@ -36,8 +36,8 @@ class AppointmentController extends Controller
{
$request->validate([
'date' => 'required|date',
'start_time' => 'required|date_format:H:i',
'end_time' => 'required|date_format:H:i',
'start_time' => 'required|date_format:H:i A',
'end_time' => 'required|date_format:H:i A',
// 'location' => 'required|max:255',
// 'description' => 'required',
]);
@ -67,8 +67,8 @@ class AppointmentController extends Controller
{
$request->validate([
'date' => 'required|date',
'start_time' => 'required|date_format:H:i',
'end_time' => 'required|date_format:H:i',
'start_time' => 'required|date_format:H:i A',
'end_time' => 'required|date_format:H:i A',
// 'location' => 'required|max:255',
// 'description' => 'required',
]);

@ -37,10 +37,9 @@ class AppointmentController extends Controller
$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) {
$start_time = date("H:i", strtotime($appointment->start_time));
$appointmentDate = Carbon::createFromFormat('Y-m-d H:i', $appointment->date.' '.$start_time);
if ($appointmentDate->gt($currentTime)) {
array_push($appointments, $appointment);
}
}

@ -20,23 +20,25 @@ class AppointmentTableSeeder extends Seeder
public function run()
{
$startTime = Carbon::parse("09:00:00");
$endTime = Carbon::parse("17:00:00");
$startTime = Carbon::parse("9:00 AM");
$endTime = Carbon::parse("5:00 PM");
foreach(config('custom.service_type') as $key => $value){
for ($i = 0; $i < 7; $i++) {
$date = Carbon::now()->addDays($i);
for ($j = 0; $j <= (($endTime->diffInMinutes($startTime)) / 30); $j++) {
for ($j = 0; $j <= ((($endTime->diffInMinutes($startTime)) / 30)-1); $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"),
'start_time' => $currentTime->format("H:i A"),
'end_time' => $currentEndTime->format("H:i A"),
'service_type' => $key
]);
}
}
}
}
}

@ -42,19 +42,19 @@
<div class="col-md-6">
<div class="form-group">
<label> Date <span style="color: red";> * </span> </label>
<input type="date" class="form-control" id="inputPassword3" name="date" value="{{$appointment->date}}" required>
<input type="date" class="form-control" id="inputPassword3" name="date" value="{{$appointment->date}}" required/>
</div>
</div>
<div class="col-md-6" >
<div class="form-group" >
<label>Start Time <span style="color: red";> * </span></label>
<input type="time" name="start_time" class="form-control" required value = "{{$appointment->start_time}}"/>
<input type="text" name="start_time" class="form-control" value = "{{$appointment->start_time}}" required/>
</div>
</div>
<div class="col-md-6" >
<div class="form-group" >
<label>End Time <span style="color: red";> * </span></label>
<input type="time" name="end_time" class="form-control" required value = "{{$appointment->end_time}}"/>
<input type="text" name="end_time" class="form-control" value = "{{$appointment->end_time}}" required/>
</div>
</div>
<div class="col-md-6">

@ -184,21 +184,24 @@
for (var i = 0; i < appointments.length; i++) {
var appointment = appointments[i];
var isAmStart = appointment.start_time < '12:00:00';
var isAmEnd = appointment.end_time < '12:00:00';
timeSlots += '<button type="button" class="time-slot" data-toggle="modal" data-target="#appointmentModal" data-appointment-id="' + appointment.id + '">' + appointment.start_time +' '+ (isAmEnd ? 'AM' : 'PM')+ ' - ' + appointment.end_time +' ' + (isAmEnd ? 'AM' : 'PM') + '</button>';
// var isAmStart = appointment.start_time < '12:00:00';
// var isAmEnd = appointment.end_time < '12:00:00';
var isAmStart = '';
var isAmEnd = '';
timeSlots += '<button type="button" class="time-slot" data-toggle="modal" data-target="#appointmentModal" data-appointment-id="' + appointment.id + '" data-start-time="'+appointment.start_time+'" + data-end-time="'+appointment.end_time+'" >' + appointment.start_time +' - ' + appointment.end_time +'</button>';
}
$('#'+id+'-available-dates').html(timeSlots);
$('.time-slot').click(function (e) {
e.preventDefault();
var appointmentId = $(this).data("appointment-id");
var startTime = $(this).data("start-time");
var endTime = $(this).data("end-time");
$('#appointment-form input[name="appointment_id"]').val(appointmentId);
$('#booking_date').html(formated_date);
$('#start_time').html('&nbsp;<b>('+appointment.start_time+'</b>');
$('#end_time').html('<b>'+appointment.end_time+')</b>');
$('#start_time').html('&nbsp;<b>('+startTime+'</b>');
$('#end_time').html('<b>'+endTime+')</b>');
$("#modal").modal("show");
});
@ -218,12 +221,12 @@
data: $("form").serialize(),
success: function(response) {
$("#modal").modal("hide");
var isAmStart = response.appointment.start_time < '12:00:00';
var isAmEnd = response.appointment.end_time < '12:00:00';
// var isAmStart = response.appointment.start_time < '12:00:00';
// var isAmEnd = response.appointment.end_time < '12:00:00';
Swal.fire({
title: 'Booked!!',
text: 'Appointment Successfully Booked for '+response.appointment_detail['name']+' at '+response.formated_date +'('+response.appointment['start_time']+' '+(isAmStart ? 'AM' : 'PM')+ ' - ' + response.appointment['end_time']+' '+ (isAmEnd ? 'AM' : 'PM') +')',
text: 'Appointment Successfully Booked for '+response.appointment_detail['name']+' at '+response.formated_date +'('+response.appointment['start_time']+' - ' + response.appointment['end_time']+' )',
icon: 'success'
}).then(function(){
location.reload();

Loading…
Cancel
Save