<?php

namespace App\Http\Controllers\Api;

use App\Http\Requests\Company\UpdateCompanyRequest;
use App\Http\Resources\CompanyResource;
use App\Models\Company;
use Illuminate\Http\Request;

class CompanyController extends ApiController
{
    public function show(Request $request): CompanyResource
    {
        $company = Company::findOrFail($this->currentCompanyId($request));
        
        return new CompanyResource($company);
    }

    public function update(UpdateCompanyRequest $request): CompanyResource
    {
        $company = Company::findOrFail($this->currentCompanyId($request));
        $company->update($request->validated());

        return new CompanyResource($company);
    }
}
