diff --git a/app/Http/Controllers/TallerController.php b/app/Http/Controllers/TallerController.php new file mode 100644 index 0000000..bdaf41a --- /dev/null +++ b/app/Http/Controllers/TallerController.php @@ -0,0 +1,77 @@ +whereIn('status', ['pending', 'in_progress', 'ready']) // Entregados/historial no se muestra, implementar vista aparte + ->orderBy('scheduled_at', 'asc') + ->get(); + + // Agrupado por estado para las columnas + $pending = $jobs->where('status', 'pending'); + $inProgress = $jobs->where('status', 'in_progress'); + $ready = $jobs->where('status', 'ready'); + + return view('taller.index', compact('pending', 'inProgress', 'ready')); + } + + /** + * Formulario para nuevo servicio + */ + public function create() + { + $clients = Client::orderBy('name')->get(); + return view('taller.create', compact('clients')); + } + + /** + * Guardar el servicio + */ + public function store(Request $request) + { + $request->validate([ + 'client_id' => 'required|exists:clients,id', + 'bike_model' => 'required|string', + 'problem_description' => 'required|string', + 'scheduled_at' => 'required|date', + 'estimated_cost' => 'nullable|numeric', + ]); + + // Buscamos el cliente para copiar su teléfono + $client = Client::find($request->client_id); + + Appointment::create([ + 'client_id' => $request->client_id, + 'contact_phone' => $request->contact_phone ?? $client->phone, + 'bike_model' => $request->bike_model, + 'problem_description' => $request->problem_description, + 'parts_needed' => $request->parts_needed, + 'estimated_cost' => $request->estimated_cost, + 'scheduled_at' => $request->scheduled_at, + 'status' => 'pending', // Estado inicial: Pendiente + ]); + + return redirect()->route('taller.index')->with('success', 'Bicicleta ingresada al taller correctamente.'); + } + + /** + * Mover de estado + */ + public function updateStatus(Request $request, Appointment $appointment) + { + $appointment->update(['status' => $request->status]); + return back()->with('success', 'Estado actualizado.'); + } +} \ No newline at end of file diff --git a/app/Models/Appointment.php b/app/Models/Appointment.php index 85d1752..87a42b2 100644 --- a/app/Models/Appointment.php +++ b/app/Models/Appointment.php @@ -11,9 +11,12 @@ class Appointment extends Model protected $fillable = [ 'client_id', + 'contact_phone', 'scheduled_at', 'bike_model', 'problem_description', + 'parts_needed', + 'estimated_cost', 'status', 'notes' ]; diff --git a/database/migrations/2026_01_23_135512_add_taller_fields_to_appointments_table.php b/database/migrations/2026_01_23_135512_add_taller_fields_to_appointments_table.php new file mode 100644 index 0000000..5f1690e --- /dev/null +++ b/database/migrations/2026_01_23_135512_add_taller_fields_to_appointments_table.php @@ -0,0 +1,35 @@ +text('parts_needed')->nullable()->after('problem_description'); + + // Costo Aproximado (Presupuesto) + $table->decimal('estimated_cost', 10, 2)->nullable()->after('parts_needed'); + + // Teléfono de contacto rápido (por si es distinto al del cliente registrado) + $table->string('contact_phone')->nullable()->after('client_id'); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('appointments', function (Blueprint $table) { + $table->dropColumn(['parts_needed', 'estimated_cost', 'contact_phone']); + }); + } +}; diff --git a/resources/views/components/taller-card.blade.php b/resources/views/components/taller-card.blade.php new file mode 100644 index 0000000..757920e --- /dev/null +++ b/resources/views/components/taller-card.blade.php @@ -0,0 +1,72 @@ +@props(['job', 'color']) + +@php + $borderColor = match($color) { + 'red' => 'border-l-red-500', + 'yellow' => 'border-l-yellow-500', + 'neon' => 'border-l-neon-lime', + default => 'border-l-gray-500' + }; +@endphp + +
{{ $job->problem_description }}
+ + @if($job->estimated_cost) +