GeoNetAgent, LDAPWeb, server-audit, server-connection
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

27 lines
715 B

<?php
namespace App\Http\Controllers\Api\Concerns;
use Illuminate\Http\JsonResponse;
trait RespondsWithJson
{
protected function ok(mixed $data = null, array $meta = [], int $status = 200): JsonResponse
{
return response()->json([
'data' => $data,
'meta' => (object) $meta,
'error' => null,
], $status);
}
protected function fail(string $message, string $error = 'error', int $status = 400, array $extra = []): JsonResponse
{
return response()->json(array_merge([
'data' => null,
'meta' => (object) [],
'error' => $error,
'message' => $message,
], $extra), $status);
}
}