Initial Laravel API import
Some checks failed
continuous-integration/drone/push Build is failing

- Complete GGZ Ecademy Laravel backend application
- RESTful API for learning products, members, filters
- Authentication and authorization system
- Database migrations and seeders
- Custom CRUD generator commands
- Email notification system
- Integration with frontend applications
This commit is contained in:
Joris Slagter
2025-12-02 17:40:21 +01:00
parent 786b6b6a78
commit df155bb13d
341 changed files with 116385 additions and 2 deletions

View File

@@ -0,0 +1,55 @@
<?php
namespace App\Http\Controllers\Response;
use App\Http\Controllers\Error\ErrorInterface;
use Illuminate\Http\Response;
class ApiResponse
{
public static function success(
array $content,
int $status = Response::HTTP_OK,
array $headers = []
): Response
{
return static::determineResponse($content, $status, false, $headers);
}
private static function determineResponse(
array $content,
int $status,
bool $error,
array $headers = []
): Response
{
return response(
[
'error' => $error,
'status' => [
'code' => $status,
'text' => Response::$statusTexts[$status],
],
'content' => $content,
],
$status,
$headers,
);
}
public static function error(
ErrorInterface $error,
array $headers = []
): Response
{
return static::determineResponse(
[
'code' => $error->getErrorCode(),
'message' => $error->getErrorMessage(),
],
$error->getStatusCode(),
true,
$headers,
);
}
}