|
|
@ -7,7 +7,6 @@ use App\Http\Controllers\Controller; |
|
|
|
|
|
|
|
|
|
|
|
use App\Models\Appointment; |
|
|
|
use App\Models\Appointment; |
|
|
|
use Illuminate\Http\Request; |
|
|
|
use Illuminate\Http\Request; |
|
|
|
use Carbon\Carbon; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class AppointmentController extends Controller |
|
|
|
class AppointmentController extends Controller |
|
|
|
{ |
|
|
|
{ |
|
|
@ -37,17 +36,16 @@ class AppointmentController extends Controller |
|
|
|
{ |
|
|
|
{ |
|
|
|
$request->validate([ |
|
|
|
$request->validate([ |
|
|
|
'date' => 'required|date', |
|
|
|
'date' => 'required|date', |
|
|
|
'start_time' => 'required|date_format:H:i', |
|
|
|
'start_time' => 'required|date_format:H:i A', |
|
|
|
'end_time' => 'required|date_format:H:i', |
|
|
|
'end_time' => 'required|date_format:H:i A', |
|
|
|
// 'location' => 'required|max:255', |
|
|
|
// 'location' => 'required|max:255', |
|
|
|
// 'description' => 'required', |
|
|
|
// 'description' => 'required', |
|
|
|
]); |
|
|
|
]); |
|
|
|
$start_time = Carbon::createFromFormat('H:i', $request->get('start_time'))->format('H:i A'); |
|
|
|
|
|
|
|
$end_time = Carbon::createFromFormat('H:i', $request->get('end_time'))->format('H:i A'); |
|
|
|
|
|
|
|
$appointment = new Appointment([ |
|
|
|
$appointment = new Appointment([ |
|
|
|
'date' => $request->get('date'), |
|
|
|
'date' => $request->get('date'), |
|
|
|
'start_time' => $start_time, |
|
|
|
'start_time' => $request->get('start_time'), |
|
|
|
'end_time' => $end_time, |
|
|
|
'end_time' => $request->get('end_time'), |
|
|
|
'location' => $request->get('location'), |
|
|
|
'location' => $request->get('location'), |
|
|
|
'description' => $request->get('description'), |
|
|
|
'description' => $request->get('description'), |
|
|
|
'service_type' => $request->get('service_type'), |
|
|
|
'service_type' => $request->get('service_type'), |
|
|
@ -60,14 +58,8 @@ class AppointmentController extends Controller |
|
|
|
|
|
|
|
|
|
|
|
public function edit($id) |
|
|
|
public function edit($id) |
|
|
|
{ |
|
|
|
{ |
|
|
|
$appointment = Appointment::findorfail($id); |
|
|
|
$appointment = Appointment::find($id); |
|
|
|
$start_time = explode(" ", $appointment->start_time); |
|
|
|
|
|
|
|
$start_time = $start_time[0]; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$end_time = explode(" ", $appointment->end_time); |
|
|
|
|
|
|
|
$end_time = $end_time[0]; |
|
|
|
|
|
|
|
$appointment['start_time'] = $start_time; |
|
|
|
|
|
|
|
$appointment['end_time'] = $end_time; |
|
|
|
|
|
|
|
return view($this->view.'edit', compact('appointment')); |
|
|
|
return view($this->view.'edit', compact('appointment')); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -75,22 +67,19 @@ class AppointmentController extends Controller |
|
|
|
{ |
|
|
|
{ |
|
|
|
$request->validate([ |
|
|
|
$request->validate([ |
|
|
|
'date' => 'required|date', |
|
|
|
'date' => 'required|date', |
|
|
|
'start_time' => 'required|date_format:H:i', |
|
|
|
'start_time' => 'required|date_format:H:i A', |
|
|
|
'end_time' => 'required|date_format:H:i', |
|
|
|
'end_time' => 'required|date_format:H:i A', |
|
|
|
// 'location' => 'required|max:255', |
|
|
|
// 'location' => 'required|max:255', |
|
|
|
// 'description' => 'required', |
|
|
|
// 'description' => 'required', |
|
|
|
]); |
|
|
|
]); |
|
|
|
$start_time = Carbon::createFromFormat('H:i', $request->get('start_time'))->format('H:i A'); |
|
|
|
|
|
|
|
$end_time = Carbon::createFromFormat('H:i', $request->get('end_time'))->format('H:i A'); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$appointment = Appointment::find($id); |
|
|
|
$appointment = Appointment::find($id); |
|
|
|
$appointment->date = $request->get('date'); |
|
|
|
$appointment->date = $request->get('date'); |
|
|
|
$appointment->start_time = $start_time; |
|
|
|
$appointment->start_time = $request->get('start_time'); |
|
|
|
$appointment->end_time = $end_time; |
|
|
|
$appointment->end_time = $request->get('end_time'); |
|
|
|
$appointment->location = $request->get('location'); |
|
|
|
$appointment->location = $request->get('location'); |
|
|
|
$appointment->description = $request->get('description'); |
|
|
|
$appointment->description = $request->get('description'); |
|
|
|
$appointment->service_type = $request->get('service_type'); |
|
|
|
$appointment->service_type = $request->get('service_type'); |
|
|
|
$appointment->status = $request->get('status'); |
|
|
|
|
|
|
|
$appointment->save(); |
|
|
|
$appointment->save(); |
|
|
|
|
|
|
|
|
|
|
|
return redirect($this->redirect)->with('success', 'Appointment has been updated'); |
|
|
|
return redirect($this->redirect)->with('success', 'Appointment has been updated'); |
|
|
|