Skip to content

Commit c1917ff

Browse files
committed
works
1 parent 28eca17 commit c1917ff

File tree

4 files changed

+55
-2
lines changed

4 files changed

+55
-2
lines changed

composer.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,12 @@
1818
"illuminate/contracts": "^9.21|^10.0|^11.0",
1919
"illuminate/queue": "^9.21|^10.0|^11.0",
2020
"illuminate/support": "^9.21|^10.0|^11.0"
21-
}
21+
},
22+
"extra": {
23+
"laravel": {
24+
"providers": [
25+
"CodeCreeper\\LaravelHelper\\LaravelHelperServiceProvider"
26+
]
27+
}
28+
}
2229
}

routes/api.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
<?php
22

3-
use Illuminate\Support\Facades\Route;
3+
use Illuminate\Support\Facades\Route;
4+
5+
Route::post('/helper', 'CodeCreeper\LaravelHelper\Http\Controllers\MainController');
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
namespace CodeCreeper\LaravelHelper\Http\Controllers;
4+
5+
//use Illuminate\Routing\Controller;
6+
7+
use Illuminate\Http\Request;
8+
9+
class MainController
10+
{
11+
public function __invoke(Request $request)
12+
{
13+
dd($request->all());
14+
}
15+
}

src/LaravelHelperServiceProvider.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
namespace CodeCreeper\LaravelHelper;
4+
5+
use Illuminate\Contracts\Foundation\CachesRoutes;
6+
use Illuminate\Support\Facades\Route;
7+
use Illuminate\Support\ServiceProvider;
8+
9+
class LaravelHelperServiceProvider extends ServiceProvider
10+
{
11+
public function boot(): void
12+
{
13+
$this->registerRoutes();
14+
}
15+
16+
protected function registerRoutes(): void
17+
{
18+
if ($this->app instanceof CachesRoutes && $this->app->routesAreCached()) {
19+
return;
20+
}
21+
22+
Route::group([
23+
'prefix' => '/api',
24+
'namespace' => 'Laravel\Horizon\Http\Controllers',
25+
], function () {
26+
$this->loadRoutesFrom(__DIR__.'/../routes/api.php');
27+
});
28+
}
29+
}

0 commit comments

Comments
 (0)