-
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a52f06d
commit f968f02
Showing
4 changed files
with
71 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
|
||
namespace Regnerisch\LaravelBeyond\Commands; | ||
|
||
use Illuminate\Console\Command; | ||
use Regnerisch\LaravelBeyond\Resolvers\AppNameSchemaResolver; | ||
|
||
class MakeMiddlewareCommand extends Command | ||
{ | ||
protected $signature = 'beyond:make:middleware {name?} {--support} {--overwrite}'; | ||
|
||
protected $description = 'Make a new middleware'; | ||
|
||
public function handle(): void | ||
{ | ||
try { | ||
$name = $this->argument('name'); | ||
$support = $this->option('support'); | ||
$overwrite = $this->option('overwrite'); | ||
|
||
$stub = $support ? 'middleware.support.stub' : 'middleware.stub'; | ||
$directory = $support ? 'Packages/Laravel/Middleware' : 'Middleware'; | ||
|
||
$schema = (new AppNameSchemaResolver($this, $name, support: $support))->handle(); | ||
|
||
beyond_copy_stub( | ||
$stub, | ||
$schema->path($directory), | ||
[ | ||
'{{ namespace }}' => $schema->namespace(), | ||
'{{ className }}' => $schema->className(), | ||
], | ||
$overwrite | ||
); | ||
|
||
$this->info('Middleware created.'); | ||
} catch (\Exception $exception) { | ||
$this->error($exception->getMessage()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
|
||
namespace App\{{ namespace }}\Middleware; | ||
|
||
use Closure; | ||
use Illuminate\Http\Request; | ||
|
||
class {{ className }} | ||
{ | ||
public function handle(Request $request, Closure $next) | ||
{ | ||
return $next($request); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
|
||
namespace Support\Packages\Laravel\Middleware; | ||
|
||
use Closure; | ||
use Illuminate\Http\Request; | ||
|
||
class {{ className }} | ||
{ | ||
public function handle(Request $request, Closure $next) | ||
{ | ||
return $next($request); | ||
} | ||
} |