<?php

namespace App\Http\Controllers;

use App\Models\SectionType;
use Illuminate\Http\Request;

class SectionTypeController extends Controller
{
    public function getNames(Request $request)
    {
        $request->validate([
            'section_ids' => 'required|array',
            'section_ids.*' => 'required|string'
        ]);

        $sectionTypes = SectionType::whereIn('id', $request->section_ids)
            ->get(['id', 'value'])
            ->pluck('value', 'id')
            ->toArray();

        return response()->json($sectionTypes);
    }
}
