diff --git a/bootstrap/app.php b/bootstrap/app.php index f1e24fc..6835c00 100644 --- a/bootstrap/app.php +++ b/bootstrap/app.php @@ -3,10 +3,9 @@ declare(strict_types=1); use Illuminate\Foundation\Application; -use Illuminate\Foundation\Configuration\Exceptions; use Illuminate\Support\Env; -return Application::configure(Env::get('APP_BASE_PATH', dirname(__DIR__))) +$app = Application::configure(Env::get('APP_BASE_PATH', dirname(__DIR__))) ->withRouting( web: __DIR__ . '/../routes/web.php', api: __DIR__ . '/../routes/api.php', @@ -16,3 +15,7 @@ return Application::configure(Env::get('APP_BASE_PATH', dirname(__DIR__))) ->withMiddleware(require __DIR__ . '/middlewares.php') ->withExceptions(require __DIR__ . '/exceptions.php') ->create(); + +$app->useAppPath($app->basePath('src/Presentation')); + +return $app; diff --git a/routes/api.php b/routes/api.php index d1b63da..f2cf552 100644 --- a/routes/api.php +++ b/routes/api.php @@ -18,7 +18,6 @@ Route::get( Route::get('/ping', fn () => response()->json('pong'))->name('api.ping'); - // * V1 API Route::prefix('v1')->name('api.v1.')->group(function () { require __DIR__ . '/apiv1.php'; diff --git a/routes/apiv1.php b/routes/apiv1.php index f957fb6..f59e564 100644 --- a/routes/apiv1.php +++ b/routes/apiv1.php @@ -7,17 +7,22 @@ use Illuminate\Support\Facades\Route; use Presentation\Api\V1\Http\Controllers\Employees\EmployeeShowController; use Presentation\Api\V1\Http\Controllers\Employees\EmployeesIndexController; +// * ROOT Route::get('/', fn () => response()->json([ 'message' => Config::string('app.name') . ' v1', 'spec' => route('api.v1.openapi'), ]))->name('root'); - +// * OPENAPI Route::get('/openapi', function () { return response()->file( base_path('documentation/OpenApi/openapi.yaml'), ['Content-Type' => 'application/yaml'] ); })->name('openapi'); -Route::get('/employees', EmployeesIndexController::class)->name('employees.index'); -Route::get('/employees/{employeeId}', EmployeeShowController::class)->name('employees.show'); + +// * EMPLOYEES +Route::prefix('employees')->group(function () { + Route::get('/', EmployeesIndexController::class)->name('employees.index'); + Route::get('/{employeeId}', EmployeeShowController::class)->name('employees.show'); +}); diff --git a/src/Infra/Providers/AppServiceProvider.php b/src/Infra/Providers/AppServiceProvider.php index ad91020..8c2ad28 100644 --- a/src/Infra/Providers/AppServiceProvider.php +++ b/src/Infra/Providers/AppServiceProvider.php @@ -5,16 +5,16 @@ declare(strict_types=1); namespace Infra\Providers; use Carbon\CarbonInterface; +use Illuminate\Cache\RateLimiting\Limit; use Illuminate\Database\Eloquent\Model; use Illuminate\Http\Request as HttpRequest; +use Illuminate\Http\Request as IlluminateRequest; use Illuminate\Support\Facades\Config; use Illuminate\Support\Facades\Date; +use Illuminate\Support\Facades\RateLimiter; use Illuminate\Support\Facades\Request; use Illuminate\Support\Facades\URL; use Illuminate\Support\ServiceProvider; -use Illuminate\Support\Facades\RateLimiter; -use Illuminate\Cache\RateLimiting\Limit; -use Illuminate\Http\Request as IlluminateRequest; use League\Uri\Http; use Shared\Pagination; @@ -90,7 +90,6 @@ class AppServiceProvider extends ServiceProvider }); } - public function toLocalInput(CarbonInterface | \DateTimeInterface | int | float | string | null $date): ?string { if ($date === null) { diff --git a/src/Presentation/Api/V1/Exceptions/ApiExceptionRenderer.php b/src/Presentation/Api/V1/Exceptions/ApiExceptionRenderer.php index 3f91592..1dcf2fa 100644 --- a/src/Presentation/Api/V1/Exceptions/ApiExceptionRenderer.php +++ b/src/Presentation/Api/V1/Exceptions/ApiExceptionRenderer.php @@ -5,10 +5,10 @@ declare(strict_types=1); namespace Presentation\Api\V1\Exceptions; use Domain\Exceptions\NotFoundException; +use Illuminate\Http\Exceptions\ThrottleRequestsException; use Illuminate\Http\JsonResponse; use Illuminate\Http\Request; use Illuminate\Support\Facades\Config; -use Illuminate\Http\Exceptions\ThrottleRequestsException; use Illuminate\Validation\ValidationException; use League\Uri\Http; use Symfony\Component\HttpFoundation\Response; @@ -58,7 +58,6 @@ final readonly class ApiExceptionRenderer )), ], 400, ['Content-Type' => self::CONTENT_TYPE]), - $e instanceof \DomainException => response()->json([ 'type' => (string) $baseUri->withPath('/errors/422'), 'title' => 'Unprocessable Entity', @@ -97,7 +96,7 @@ final readonly class ApiExceptionRenderer $detail = $e->getMessage() ?: $title; } - $headers = $e instanceof HttpExceptionInterface ? $e->getHeaders() : []; + $headers = $e instanceof HttpExceptionInterface ? $e->getHeaders() : []; $headers['Content-Type'] = self::CONTENT_TYPE; return response()->json([ diff --git a/src/Presentation/Web/Http/Controllers/ErrorDocumentationController.php b/src/Presentation/Web/Http/Controllers/ErrorDocumentationController.php index bd48f2c..58b3680 100644 --- a/src/Presentation/Web/Http/Controllers/ErrorDocumentationController.php +++ b/src/Presentation/Web/Http/Controllers/ErrorDocumentationController.php @@ -5,7 +5,6 @@ declare(strict_types=1); namespace Presentation\Web\Http\Controllers; use Illuminate\Contracts\View\View; - use Symfony\Component\HttpFoundation\Response; final class ErrorDocumentationController @@ -18,7 +17,7 @@ final class ErrorDocumentationController $viewName = 'errors.docs.' . $code; - if (!view()->exists($viewName)) { + if (! view()->exists($viewName)) { abort(404); }