<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\UNSPSC;

class UNSPSCController extends Controller
{
    public function search(Request $request)
    {
        $query = $request->get('query', '');

        $results = UNSPSC::where('itemClsNm', 'LIKE', '%' . $query . '%')
                          ->orWhere('itemClsCd', 'LIKE', '%' . $query . '%')
                          ->take(10)
                          ->get();

        return response()->json($results);
    }
}

