<?php

namespace App\Http\Controllers;

use App\Models\SiteSetting;
use App\Models\Testimonial;
use Illuminate\Http\Request;

class LandingController extends Controller
{
    public function index()
    {
        $settings = SiteSetting::all()->pluck('value', 'key')->toArray();
        $testimonials = Testimonial::active()->get();

        // Parse JSON fields
        $features = json_decode($settings['features'] ?? '[]', true) ?? [];
        $services = json_decode($settings['services'] ?? '[]', true) ?? [];
        $social_medias = json_decode($settings['social_media'] ?? '[]', true) ?? [];

        return view('welcome', compact('settings', 'testimonials', 'features', 'services', 'social_medias'));
    }
}
