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