<?php

namespace App\Http\Controllers\Api;

use App\Http\Controllers\Controller;
use App\Models\Homepage;
use Illuminate\Http\JsonResponse;

class HomepageController extends Controller
{
    public function index(): JsonResponse
    {
        $data = Homepage::first();

        return response()->json([
            'status' => 'success',
            'data' => [
                'photo' => $data->photo ? '/storage/' . $data->photo : null,
                'photo_mobile' => $data->photo_mobile ? '/storage/' . $data->photo_mobile : null,
                'photo_menu' => $data->photo_menu ? '/storage/' . $data->photo_menu : null,
                'title' => $data->title,
                'body' => $data->body,
                'address' => $data->address,
                'delivery' => $data->delivery,
                'opening_hours' => $data->opening_hours,
                'widget_link' => $data->widget_link
            ]
        ]);
    }
}
