resetPage(); } public function updatedDateTo(): void { $this->resetPage(); } public function clearFilters(): void { $this->dateFrom = ''; $this->dateTo = ''; $this->resetPage(); } public function quickApprove(int $id): void { $consultation = Consultation::with('user')->findOrFail($id); if ($consultation->status !== ConsultationStatus::Pending) { session()->flash('error', __('admin.booking_already_processed')); return; } $oldStatus = $consultation->status->value; $consultation->update([ 'status' => ConsultationStatus::Approved, 'consultation_type' => ConsultationType::Free, 'payment_status' => PaymentStatus::NotApplicable, ]); // Generate calendar file and send notification $icsContent = null; try { $calendarService = app(CalendarService::class); $icsContent = $calendarService->generateIcs($consultation); } catch (\Exception $e) { Log::error('Failed to generate calendar file', [ 'consultation_id' => $consultation->id, 'error' => $e->getMessage(), ]); } // Send appropriate notification/email based on guest/client if ($consultation->isGuest()) { Mail::to($consultation->guest_email)->queue( new GuestBookingApprovedMail( $consultation, app()->getLocale() ) ); } elseif ($consultation->user) { $consultation->user->notify( new BookingApproved($consultation, $icsContent ?? '', null) ); } // Log action AdminLog::create([ 'admin_id' => auth()->id(), 'action' => 'approve', 'target_type' => 'consultation', 'target_id' => $consultation->id, 'old_values' => ['status' => $oldStatus], 'new_values' => [ 'status' => ConsultationStatus::Approved->value, 'consultation_type' => ConsultationType::Free->value, ], 'ip_address' => request()->ip(), 'created_at' => now(), ]); session()->flash('success', __('admin.booking_approved')); } public function quickReject(int $id): void { $consultation = Consultation::with('user')->findOrFail($id); if ($consultation->status !== ConsultationStatus::Pending) { session()->flash('error', __('admin.booking_already_processed')); return; } $oldStatus = $consultation->status->value; $consultation->update([ 'status' => ConsultationStatus::Rejected, ]); // Send appropriate notification/email based on guest/client if ($consultation->isGuest()) { Mail::to($consultation->guest_email)->queue( new GuestBookingRejectedMail( $consultation, app()->getLocale(), null ) ); } elseif ($consultation->user) { $consultation->user->notify( new BookingRejected($consultation, null) ); } // Log action AdminLog::create([ 'admin_id' => auth()->id(), 'action' => 'reject', 'target_type' => 'consultation', 'target_id' => $consultation->id, 'old_values' => ['status' => $oldStatus], 'new_values' => [ 'status' => ConsultationStatus::Rejected->value, ], 'ip_address' => request()->ip(), 'created_at' => now(), ]); session()->flash('success', __('admin.booking_rejected')); } public function with(): array { return [ 'bookings' => Consultation::query() ->where('status', ConsultationStatus::Pending) ->when($this->dateFrom, fn ($q) => $q->where('booking_date', '>=', $this->dateFrom)) ->when($this->dateTo, fn ($q) => $q->where('booking_date', '<=', $this->dateTo)) ->with('user:id,full_name,email,phone,user_type') ->orderBy('booking_date') ->orderBy('booking_time') ->paginate(15), ]; } }; ?>
{{ Str::limit($booking->problem_summary, 150) }}
{{ __('admin.no_pending_bookings') }}