<?php

namespace App\Http\Controllers\Api;

use App\Http\Controllers\Controller;
use App\Models\History;
use App\Models\ProfilePart;
use App\Supports\Response;
use Carbon\Carbon;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;

/**
 * @group Lottery Prize
 */
class ProfilePageController extends Controller
{
    public function __construct(
    )
    {
    }

    public function list($locale = 'tw')
    {
        $locale = $locale == "tw" ? "zh_TW" : $locale;
        $data = ProfilePart::where("visible", 1)->orderByDesc("order")->get();
        $result = [];
        foreach($data as $item){
            $result["list"][] = [
                "title" => $item->getTranslation("title", $locale),
                "content" => $item->getTranslation("content", $locale),
                "imgUrl" => $item->img_url_link,
                "alt" => $item->getTranslation("img_alt", $locale)
            ];
        }
        return Response::ok($result);
    }
}
