Skip to content

Commit

Permalink
refactor: use controller to respond with view
Browse files Browse the repository at this point in the history
  • Loading branch information
hanspagel committed Sep 12, 2024
1 parent be1aeb9 commit 860e81c
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 21 deletions.
10 changes: 5 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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/"
}
},
Expand Down Expand Up @@ -69,10 +69,10 @@
"extra": {
"laravel": {
"providers": [
"Scalar\\Scalar\\ScalarServiceProvider"
"Scalar\\ScalarServiceProvider"
],
"aliases": {
"Scalar": "Scalar\\Scalar\\Facades\\Scalar"
"Scalar": "Scalar\\Facades\\Scalar"
}
}
},
Expand Down
2 changes: 1 addition & 1 deletion database/factories/ModelFactory.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Scalar\Scalar\Database\Factories;
namespace Scalar\Database\Factories;

use Illuminate\Database\Eloquent\Factories\Factory;

Expand Down
3 changes: 2 additions & 1 deletion routes/web.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
<?php

use Illuminate\Support\Facades\Route;
use Scalar\Controllers\ScalarController;

Route::group([
'domain' => config('scalar.domain', null),
'prefix' => config('scalar.path'),
'middleware' => config('scalar.middleware', 'web'),
], function () {
Route::view('/', 'scalar::reference');
Route::get('/', ScalarController::class);
});
2 changes: 1 addition & 1 deletion src/Commands/ScalarCommand.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Scalar\Scalar\Commands;
namespace Scalar\Commands;

use Illuminate\Console\Command;

Expand Down
13 changes: 13 additions & 0 deletions src/Controllers/ScalarController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace Scalar\Controllers;

use Illuminate\Routing\Controller;

class ScalarController extends Controller
{
public function __invoke()
{
return view('scalar::reference');
}
}
6 changes: 3 additions & 3 deletions src/Facades/Scalar.php
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<?php

namespace Scalar\Scalar\Facades;
namespace Scalar\Facades;

use Illuminate\Support\Facades\Facade;

/**
* @see \Scalar\Scalar\Scalar
* @see \Scalar\Scalar
*/
class Scalar extends Facade
{
protected static function getFacadeAccessor(): string
{
return \Scalar\Scalar\Scalar::class;
return \Scalar\Scalar::class;
}
}
2 changes: 1 addition & 1 deletion src/Scalar.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Scalar\Scalar;
namespace Scalar;

class Scalar
{
Expand Down
8 changes: 2 additions & 6 deletions src/ScalarServiceProvider.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Scalar\Scalar;
namespace Scalar;

use Spatie\LaravelPackageTools\Package;
use Spatie\LaravelPackageTools\PackageServiceProvider;
Expand All @@ -9,15 +9,11 @@ class ScalarServiceProvider extends PackageServiceProvider
{
public function configurePackage(Package $package): void
{
/*
* This class is a Package Service Provider
*
* More info: https://github.com/spatie/laravel-package-tools
*/
$package
->name('scalar')
->hasConfigFile()
->hasViews('scalar')
->hasRoute('web');

}
}
2 changes: 1 addition & 1 deletion tests/Pest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php

use Scalar\Scalar\Tests\TestCase;
use Scalar\Tests\TestCase;

uses(TestCase::class)->in(__DIR__);
4 changes: 2 additions & 2 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php

namespace Scalar\Scalar\Tests;
namespace Scalar\Tests;

use Illuminate\Database\Eloquent\Factories\Factory;
use Orchestra\Testbench\TestCase as Orchestra;
use Scalar\Scalar\ScalarServiceProvider;
use Scalar\ScalarServiceProvider;

class TestCase extends Orchestra
{
Expand Down

0 comments on commit 860e81c

Please sign in to comment.