Skip to content

Commit

Permalink
Merge pull request #8 from regnerisch/feature/route-command-v2
Browse files Browse the repository at this point in the history
Feature/route command v2
  • Loading branch information
regnerisch authored Feb 18, 2022
2 parents 27ba00e + 19469b7 commit 9adf123
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 0 deletions.
36 changes: 36 additions & 0 deletions src/Commands/MakeRouteCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

namespace Regnerisch\LaravelBeyond\Commands;

use Illuminate\Console\Command;

class MakeRouteCommand extends Command
{
protected $signature = 'beyond:make:route {routeName}';

protected $description = 'Make a new file for routes';

public function handle()
{
$routeName = $this->argument('routeName');
$routeNameLowerCase = mb_strtolower($routeName);

beyond_copy_stub(
'routes.stub',
base_path() . "/routes/{$routeNameLowerCase}.php",
[
'{{ application }}' => $routeNameLowerCase,
]
);


$this->info(
"Please add following route entry to your RouteServiceProvider. Please take care of using the correct middleware. This could differ from the default middleware." . PHP_EOL . PHP_EOL .

"\tRoute::prefix('{$routeNameLowerCase}')" . PHP_EOL .
"\t\t->middleware('api')" . PHP_EOL .
"\t\t->namespace($this->namespace)" . PHP_EOL .
"\t\t->group(base_path('routes/{$routeNameLowerCase}.php'));"
);
}
}
2 changes: 2 additions & 0 deletions src/LaravelBeyondServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use Regnerisch\LaravelBeyond\Commands\MakeQueryCommand;
use Regnerisch\LaravelBeyond\Commands\MakeRequestCommand;
use Regnerisch\LaravelBeyond\Commands\MakeResourceCommand;
use Regnerisch\LaravelBeyond\Commands\MakeRouteCommand;
use Regnerisch\LaravelBeyond\Commands\SetupCommand;

class LaravelBeyondServiceProvider extends ServiceProvider
Expand All @@ -29,6 +30,7 @@ public function boot()
MakeQueryCommand::class,
MakeRequestCommand::class,
MakeResourceCommand::class,
MakeRouteCommand::class,
SetupCommand::class,
]);
}
Expand Down
18 changes: 18 additions & 0 deletions stubs/routes.stub
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

use Illuminate\Support\Facades\Route;

/*
|--------------------------------------------------------------------------
| {{ application }} Routes
|--------------------------------------------------------------------------
|
| Here is where you can register routes for {{ application }}. These
| routes needs to be added to the RouteServiceProvider.
| Now create something great!
|
*/

Route::get('/{{ application }}/', function () {
return view('welcome');
});

0 comments on commit 9adf123

Please sign in to comment.