<?php

namespace App\Http\Controllers\Api;

use App\Http\Controllers\Controller;
use App\Http\Resources\SkillResource;
use App\Models\Skill;

class SkillController extends Controller
{
    public function index()
    {
        $skills = Skill::ordered()->get()->groupBy('category');

        $grouped = $skills->map(fn ($group) => SkillResource::collection($group));

        return response()->json([
            'data' => $grouped,
            'meta' => ['lang' => app()->getLocale()],
        ]);
    }
}
