<?php

namespace Modules\Admin\app\Http\Controllers;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Modules\Admin\app\Models\Category;

class CategoryController extends Controller
{
    /**
     * Retrieves a list of master data based on the given request type.
     *
     * @param Request $request The HTTP request object.
     * @return \Illuminate\Http\JsonResponse The JSON response containing the list of master data.
     */
    public function getListMaster(Request $request)
    {
        $data = Category::where('c_type', '=', $request->type)->where('c_active', '=', 1)->select('id', 'c_code', 'c_name', 'c_value', 'c_type')->get();
        return AbstractController::ResultSuccess($data);
    }
    public static function getListMasterByCodeAndType($type, $code)
    {
        $data = Category::where('c_type', '=', $type)->where('c_code', '=', $code)->where('c_active', '=', 1)->select('id', 'c_code', 'c_name', 'c_value', 'c_type')->first();
        return $data;
    }
}
