mirror of
https://github.com/sp-tarkov/forge.git
synced 2025-02-13 04:30:41 -05:00
Includes routes for login, logout, listing users, listing mods, listing a user, and listing a mod. Very basic, just laying out the structure. https://www.postman.com/refringe/workspace/spt-forge
27 lines
650 B
PHP
27 lines
650 B
PHP
<?php
|
|
|
|
namespace App\Traits;
|
|
|
|
use Illuminate\Http\JsonResponse;
|
|
|
|
trait ApiResponses
|
|
{
|
|
protected function success(string $message, ?array $data = []): JsonResponse
|
|
{
|
|
return $this->baseResponse(message: $message, data: $data, code: 200);
|
|
}
|
|
|
|
private function baseResponse(?string $message = '', ?array $data = [], ?int $code = 200): JsonResponse
|
|
{
|
|
return response()->json([
|
|
'message' => $message,
|
|
'data' => $data,
|
|
], $code);
|
|
}
|
|
|
|
protected function error(string $message, int $code): JsonResponse
|
|
{
|
|
return $this->baseResponse(message: $message, code: $code);
|
|
}
|
|
}
|