<?php

namespace App\Http\Controllers;

use App\Models\AboutUs;
use App\Models\Service;
use App\Models\Testimonial;
use Illuminate\Http\Request;

class AboutUsController extends Controller
{
    public function __invoke()
    {
        $about = AboutUs::first();
        if ($about) {
            $testimonial = Testimonial::all()->makeHidden(['created_at', 'updated_at']);
            $services = Service::select('id', 'name', 'icon')
                ->where('show_in_about', true)
                ->get();
            $about->testimonials = $testimonial;
            $about->services = $services;
            return $about->makeHidden(['id', 'created_at', 'updated_at']);
        } else {
            return response()->json(['message' => 'No record found'], 401);
        }
    }
}
