<?php

namespace Modules\Setting\Controllers\Api;

/** Ajax Request */

use App\Services\Response\ResponseService;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Modules\Page\Models\Resources\PageResource;
use Modules\Page\Services\PageService;
use Modules\Setting\Services\SettingService;

class SettingController extends Controller
{
    public function __construct(
        private SettingService $settingService,
        private PageService $pageService
    ){}

    public function settings(Request $request)
    {
        $request->merge(['ids'=>[7,8,9]]);
        $pages = $this->pageService->get($request);
        $policy = $this->pageService->getItemById(3);
        $conditions = $this->pageService->getItemById(4);
        $items = $this->pageService->getItemById(5);

        $settings = $this->settingService->getAll();
        return ResponseService::response([
            'message' => '',
            'data' =>
            [
                'settings'=>$settings,
                'intro'=>PageResource::collection($pages),
                'policy'=>new PageResource($policy),
                'conditions'=>new PageResource($conditions),
                'items'=>new PageResource($items),
            ],
            'status' => 200
        ]);
    }
}
