Implement package limit notification system
This commit is contained in:
30
app/Support/ApiError.php
Normal file
30
app/Support/ApiError.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Support;
|
||||
|
||||
use Illuminate\Http\JsonResponse;
|
||||
|
||||
class ApiError
|
||||
{
|
||||
public static function response(
|
||||
string $code,
|
||||
string $title,
|
||||
string $message,
|
||||
int $status,
|
||||
array $meta = []
|
||||
): JsonResponse {
|
||||
$payload = [
|
||||
'error' => [
|
||||
'code' => $code,
|
||||
'title' => $title,
|
||||
'message' => $message,
|
||||
],
|
||||
];
|
||||
|
||||
if ($meta !== []) {
|
||||
$payload['error']['meta'] = $meta;
|
||||
}
|
||||
|
||||
return response()->json($payload, $status);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user