<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Models\Sector;
use App\Http\Requests\CreateSectorRequest;

class SectorController extends Controller
{
    public function index()
    {
        $sectors = Sector::select('id', 'name', 'slug', 'is_active')->get();

        return response()->json([
            'message' => 'Setores obtidos com sucesso',
            'data' => $sectors,
            'errors' => null,
        ], 200);
    }

    public function create(CreateSectorRequest $request)
    {
        $sector = Sector::create($request->validated());
        return response()->json([
            'message' => 'Setor criado com sucesso',
            'data' => $sector,
            'errors' => null,
        ], 201);
    }
}
