Skip to content

Commit

Permalink
Merge pull request #15 from savannabits/0.x-dev
Browse files Browse the repository at this point in the history
New Feature: Generate Request Class
  • Loading branch information
coolsam726 authored Apr 7, 2024
2 parents ccb05b2 + 504f24b commit 052332f
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/Commands/ControllerMakeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,14 +109,16 @@ protected function generateFormRequests($modelClass, $storeRequestClass, $update
{
$storeRequestClass = 'Store'.class_basename($modelClass).'Request';

$this->call('make:request', [
$this->call('modular:make-request', [
'name' => $storeRequestClass,
'module' => $this->getModule()->name(),
]);

$updateRequestClass = 'Update'.class_basename($modelClass).'Request';

$this->call('make:request', [
$this->call('modular:make-request', [
'name' => $updateRequestClass,
'module' => $this->getModule()->name(),
]);

return [$storeRequestClass, $updateRequestClass];
Expand Down
3 changes: 2 additions & 1 deletion src/Commands/ModelMakeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,9 @@ protected function createPolicy(): void
{
$policy = Str::studly(class_basename($this->argument('name')));

$this->call('make:policy', [
$this->call('modular:make-policy', [
'name' => "{$policy}Policy",
'module' => $this->getModule()->name(),
'--model' => $this->qualifyClass($this->getNameInput()),
]);
}
Expand Down
19 changes: 19 additions & 0 deletions src/Commands/RequestMakeCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

namespace Savannabits\Modular\Commands;

use Savannabits\Modular\Support\Concerns\GeneratesModularFiles;

class RequestMakeCommand extends \Illuminate\Foundation\Console\RequestMakeCommand
{
use GeneratesModularFiles;

protected $name = 'modular:make-request';

protected $description = 'Create a new form request class in a modular package';

protected function getRelativeNamespace(): string
{
return '\\Http\\Requests';
}
}
1 change: 1 addition & 0 deletions src/ModularServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public function configurePackage(Package $package): void
->hasConfigFile('modular')
->hasViews(static::$viewNamespace)
->hasCommands($this->getCommands())
->hasMigrations($this->getMigrationFiles())
->hasInstallCommand(function (InstallCommand $command) {
// get repo name from composer.json
$name = json_decode(file_get_contents(base_path('composer.json')))?->name;
Expand Down

0 comments on commit 052332f

Please sign in to comment.