<?php

namespace App\Http\Controllers\Api\System;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\Models\Job;
use App\Models\Company;

class SearchController extends Controller
{
    public function search(Request $request)
    {
        $keyword = $request->keyword;

        $jobs = Job::where('title','like','%'.$keyword.'%')
            ->limit(5)
            ->get();

        $companies = Company::where('company_name','like','%'.$keyword.'%')
            ->limit(5)
            ->get();

        return response()->json([
            'jobs' => $jobs,
            'companies' => $companies
        ]);
    }
}