Initial commit

This commit is contained in:
meusinfirmary
2025-04-22 14:33:37 +07:00
commit b9891d2f81
1305 changed files with 452033 additions and 0 deletions

110
app/Responses.php Executable file
View File

@ -0,0 +1,110 @@
<?php
namespace App;
class Responses
{
public static function success($msg = null)
{
$apiResp = [
'meta' => [
'code' => 200,
'type' => 'success',
'message' => 'success',
],
];
if ($msg) $apiResp['meta']['message'] = $msg;
return $apiResp;
}
public static function created($msg = null)
{
$apiResp = [
'meta' => [
'code' => 201,
'type' => 'success',
'message' => 'created',
],
];
if ($msg) $apiResp['meta']['message'] = $msg;
return $apiResp;
}
public static function accepted($msg = null)
{
$apiResp = [
'meta' => [
'code' => 202,
'type' => 'success',
'message' => 'accepted',
],
];
if ($msg) $apiResp['meta']['message'] = $msg;
return $apiResp;
}
public static function bad_request($msg = null)
{
$apiResp = [
'meta' => [
'code' => 400,
'type' => 'bad_request',
'message' => 'bad request',
],
];
if ($msg) $apiResp['meta']['message'] = $msg;
return $apiResp;
}
public static function not_found($msg = null)
{
$apiResp = [
'meta' => [
'code' => 404,
'type' => 'not_found',
'message' => 'not found',
],
];
if ($msg) $apiResp['meta']['message'] = $msg;
return $apiResp;
}
public static function bad_input($msg = null)
{
$apiResp = [
'meta' => [
'code' => 422,
'type' => 'unprocessable_entity',
'message' => 'bad input',
],
];
if ($msg) $apiResp['meta']['message'] = $msg;
return $apiResp;
}
public static function error($msg = null)
{
$apiResp = [
'meta' => [
'code' => 500,
'type' => 'error',
'message' => 'error',
],
];
if (env('APP_DEBUG')) $apiResp['meta']['message'] = $msg;
return $apiResp;
}
}