From 860e81c6dad8cc49ebb9cbf505dbd6838ea9231c Mon Sep 17 00:00:00 2001 From: Hans Pagel Date: Thu, 12 Sep 2024 16:53:56 +0200 Subject: [PATCH] refactor: use controller to respond with view --- composer.json | 10 +++++----- database/factories/ModelFactory.php | 2 +- routes/web.php | 3 ++- src/Commands/ScalarCommand.php | 2 +- src/Controllers/ScalarController.php | 13 +++++++++++++ src/Facades/Scalar.php | 6 +++--- src/Scalar.php | 2 +- src/ScalarServiceProvider.php | 8 ++------ tests/Pest.php | 2 +- tests/TestCase.php | 4 ++-- 10 files changed, 31 insertions(+), 21 deletions(-) create mode 100644 src/Controllers/ScalarController.php diff --git a/composer.json b/composer.json index 7d887fd..b485570 100644 --- a/composer.json +++ b/composer.json @@ -31,13 +31,13 @@ }, "autoload": { "psr-4": { - "Scalar\\Scalar\\": "src/", - "Scalar\\Scalar\\Database\\Factories\\": "database/factories/" + "Scalar\\": "src/", + "Scalar\\Database\\Factories\\": "database/factories/" } }, "autoload-dev": { "psr-4": { - "Scalar\\Scalar\\Tests\\": "tests/", + "Scalar\\Tests\\": "tests/", "Workbench\\App\\": "workbench/app/" } }, @@ -69,10 +69,10 @@ "extra": { "laravel": { "providers": [ - "Scalar\\Scalar\\ScalarServiceProvider" + "Scalar\\ScalarServiceProvider" ], "aliases": { - "Scalar": "Scalar\\Scalar\\Facades\\Scalar" + "Scalar": "Scalar\\Facades\\Scalar" } } }, diff --git a/database/factories/ModelFactory.php b/database/factories/ModelFactory.php index 071babf..35b246c 100644 --- a/database/factories/ModelFactory.php +++ b/database/factories/ModelFactory.php @@ -1,6 +1,6 @@ config('scalar.domain', null), 'prefix' => config('scalar.path'), 'middleware' => config('scalar.middleware', 'web'), ], function () { - Route::view('/', 'scalar::reference'); + Route::get('/', ScalarController::class); }); diff --git a/src/Commands/ScalarCommand.php b/src/Commands/ScalarCommand.php index 155f227..bd2c542 100644 --- a/src/Commands/ScalarCommand.php +++ b/src/Commands/ScalarCommand.php @@ -1,6 +1,6 @@ name('scalar') ->hasConfigFile() ->hasViews('scalar') ->hasRoute('web'); + } } diff --git a/tests/Pest.php b/tests/Pest.php index c6275d6..c387027 100644 --- a/tests/Pest.php +++ b/tests/Pest.php @@ -1,5 +1,5 @@ in(__DIR__); diff --git a/tests/TestCase.php b/tests/TestCase.php index fe77f9e..10a2c95 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -1,10 +1,10 @@