<?php

namespace App\Http\Controllers\V3;

use App\Http\Controllers\Controller;
use App\Http\Traits\ApiResponse;
use App\Models\Rahdaran;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;

class RahdaranController extends Controller
{
    use ApiResponse;

    public function list(): JsonResponse
    {
        $rahdaranList = Rahdaran::query()->get();

        return $this->successResponse($rahdaranList);
    }

    public function search(Request $request): JsonResponse
    {
        $matchedSearchedRahdaran = Rahdaran::query()
            ->where('code', 'LIKE', "%{$request->code}%")
            ->get();

        return $this->successResponse($matchedSearchedRahdaran);
    }
}
