<?php

namespace App\Http\Controllers;

use App\Models\Solution;
use App\Models\ProcessStep;
use App\Models\SiteSetting;

class SolutionPageController extends Controller
{
    private function settings(): array
    {
        return SiteSetting::pluck('value', 'key')->toArray();
    }

    public function index()
    {
        $solutions = Solution::where('is_active', 1)->orderBy('sort_order')->get();
        $steps     = ProcessStep::where('is_active', 1)->orderBy('sort_order')->get();
        $settings  = $this->settings();

        return view('pages.solutions', compact('solutions', 'steps', 'settings'));
    }

    public function show(string $slug)
    {
        $solution = Solution::where('slug', $slug)
            ->where('is_active', 1)
            ->firstOrFail();

        $settings = $this->settings();

        return view('pages.solution-detail', compact('solution', 'settings'));
    }
}
