<?php

namespace App\Http\Controllers\Api\V1;

use App\Http\Controllers\Controller;
use App\Models\WS\AboutUs;
use App\Models\WS\Contact;
use App\Models\WS\Gallery;
use App\Models\WS\Menu;
use App\Models\WS\Service;
use App\Models\WS\Slide;
use App\Models\WS\Vision;
use Illuminate\Http\Request;

class HomeController extends Controller
{
    public function index()
    {
        $data = [
            'aboutUs' => $this->aboutUs(),
            'visions' => $this->visions(),
            'menus' => $this->menus(),
            'services' => $this->services(),
            'slides' => $this->slides(),
            'galleries' => $this->galleries(),
            'contact' => $this->contact()
        ];
        return response()->json($data);
    }

    private function aboutUs()
    {
        return AboutUs::first();
    }

    private function visions()
    {
        return Vision::all();
    }

    private function menus()
    {
        return Menu::all();
    }

    private function services()
    {
        return Service::all();
    }

    private function slides()
    {
        return Slide::all();
    }

    private function galleries()
    {
        return Gallery::all()->map(function ($row) {
            return $row->image_url;
        });
    }

    private function contact()
    {
        return Contact::first();
    }
}
