<?php

namespace App\Http\Controllers;

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

class CompanyController extends Controller
{
    public function store(Request $request)
    {
        $request->validate([
            'name' => 'required|string|max:255|unique:companies,name',
        ]);

        $company = Company::create([
            'name' => $request->name,
        ]);

        return response()->json([
            'success' => true,
            'message' => 'Company added successfully!',
            'data' => $company,
        ]);
    }
}
