change response json

This commit is contained in:
Muhammad Fajar
2022-11-03 10:50:27 +07:00
parent c6f5d129c2
commit b96c6726e9
10 changed files with 62 additions and 123 deletions

View File

@@ -4,6 +4,7 @@ namespace App\Helpers;
use Carbon\Carbon;
use Carbon\CarbonPeriod;
use Illuminate\Http\JsonResponse;
use Symfony\Component\HttpFoundation\Response;
class Helper
@@ -144,12 +145,20 @@ class Helper
return (object) $schedules;
}
public static function currencyIdrFormat($price)
public static function currencyIdrFormat(int $price)
{
return "Rp. " . number_format($price, 0, ',', '.');
}
public static function responseJson($data = [], $statusCode = Response::HTTP_OK, $message = 'Data berhasil di ambil')
/**
* Helper Response Json.
*
* @param array|object $data
* @param int $statusCode
* @param string $message
* @return JsonResponse
*/
public static function responseJson(array|object $data = [], int $statusCode = Response::HTTP_OK, string $message = 'Data berhasil di ambil'): JsonResponse
{
return response()->json([
'status' => $statusCode != 200 ? 'error' : 'success',