<?php

namespace App\Http\Controllers;

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

class IndustryCategoryController extends Controller
{
    public function __invoke()
    {
        $about = IndustryCategory::all();

        if ($about) {
            return $about->makeHidden(['id', 'created_at', 'updated_at']);
        } else {
            return response()->json(['message' => 'No record found'], 404);
        }
    }

    public function by_id(string $id)
    {
        $about = IndustryCategory::find($id);

        if ($about) {
            return $about->makeHidden(['id', 'created_at', 'updated_at']);
        } else {
            return response()->json(['message' => 'No record found'], 404);
        }
    }
    public function navBar()
    {
        $service = IndustryCategory::select('id', 'name')
            ->with([
                'industries:id,name,mini_description,icon'
            ])
            ->get();
        if ($service->isEmpty()) {
            return response()->json(['message' => 'No record found'], 404);
        }
        return response()->json($service);
    }
}
