<?php

namespace App\Http\Controllers\Frontend;

use App\Http\Controllers\Controller;
use App\Models\Faq;
use App\Models\Service;
use App\Models\ServiceCategory;
use App\Models\Testimonial;
use Illuminate\Http\Request;

class ServiceController extends Controller
{
    public function index()
    {
        $categories = ServiceCategory::with(['activeServices.packages'])
            ->where('is_active', true)
            ->orderBy('sort_order')
            ->get();

        return view('frontend.services.index', compact('categories'));
    }

    public function show(Service $service)
    {
        $service->load(['category', 'packages', 'requirements', 'faqs']);

        $relatedServices = Service::where('service_category_id', $service->service_category_id)
            ->where('id', '!=', $service->id)
            ->where('is_active', true)
            ->take(3)
            ->get();

        $testimonials = Testimonial::where('is_active', true)
            ->orderBy('sort_order')
            ->take(3)
            ->get();

        return view('frontend.services.show', compact('service', 'relatedServices', 'testimonials'));
    }
}
