Files
LauckCycles/app/Http/Controllers/AgendaController.php
T

39 lines
1.2 KiB
PHP

<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Models\Appointment;
class AgendaController extends Controller
{
public function index()
{
$all_appointments = Appointment::with('client')->get();
$appointments = [];
foreach($all_appointments as $appointment){
$appointments[] = [
'id' => $appointment->id,
'title' => $appointment->scheduled_at->format('H:i') . ' - ' . $appointment->client->name,
'start' => $appointment->scheduled_at->format('Y-m-d\TH:i:s'),
'extendedProps' => [
'client_name' => $appointment->client->name,
'client_phone' => $appointment->contact_phone,
'bike_model' => $appointment->bike_model,
'description' => $appointment->problem_description,
'parts_needed' => $appointment->parts_needed,
'estimated_cost'=> $appointment->estimated_cost,
'status' => $appointment->status,
'notes' => $appointment->notes,
],
];
}
return view('agenda', compact('appointments'));
}
}