<?php

namespace Modules\FAQ\Http\Controllers;

use App\Functions\ResponseHelper;
use App\Http\Controllers\BasicController;
use Modules\FAQ\Entities\Model;

class APIController extends BasicController
{
    public function show()
    {
        $backgroundColors = [
            'rgba(173, 216, 230, 0.5)', // Light blue
            'rgba(255, 182, 193, 0.5)', // Light pink
            'rgba(240, 128, 128, 0.5)', // Light coral
            'rgba(135, 206, 235, 0.5)', // Sky blue
            'rgba(144, 238, 144, 0.5)', // Light green
            'rgba(255, 222, 173, 0.5)', // Navajo white
            'rgba(221, 160, 221, 0.5)', // Plum
            'rgba(255, 239, 213, 0.5)', // Papaya whip
            'rgba(255, 228, 225, 0.5)', // Misty rose
            'rgba(224, 255, 255, 0.5)',  // Light cyan
        ];

        $Model = Model::select('title_'.lang().' AS title', 'desc_'.lang().' AS desc', 'file as image')
            ->where('id', request('id'))
            ->first();

        $Model->image = asset($Model->image);
        $Model->bg = $backgroundColors[array_rand($backgroundColors)];

        return ResponseHelper::make($Model);
    }
}
