<?php

namespace App\Components;

use Illuminate\Support\Facades\Gate;
use Maatwebsite\Excel\Facades\Excel;

trait ApiProcurementResponse{

    public function success($data = null,$message = null): \Illuminate\Http\JsonResponse
    {
        $status_code=200;
        $result = ['status'=>1];
        if ($data)$result["data"] = $data;
        if ($message)$result["message"] = $message;
        return response()->json($result,$status_code);
    }

    public function error($message = null): \Illuminate\Http\JsonResponse
    {
        $status_code=401;
        $result = ['status'=>0,'message'=>$message];
        if ($message)$result["message"] = $message;
        return response()->json($result,$status_code);
    }
}
