Skip to content

Commit

Permalink
[7.x] Publish the form request stub used by RequestMakeCommand (#31962)
Browse files Browse the repository at this point in the history
* Publish the form request stub used by RequestMakeCommand.php

* Update request.stub namespace and class for consistency
  • Loading branch information
hailwood committed Mar 15, 2020
1 parent 86114a8 commit f5b6f3b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
15 changes: 14 additions & 1 deletion src/Illuminate/Foundation/Console/RequestMakeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,20 @@ class RequestMakeCommand extends GeneratorCommand
*/
protected function getStub()
{
return __DIR__.'/stubs/request.stub';
return $this->resolveStubPath('/stubs/request.stub');
}

/**
* Resolve the fully-qualified path to the stub.
*
* @param string $stub
* @return string
*/
protected function resolveStubPath($stub)
{
return file_exists($customPath = $this->laravel->basePath(trim($stub, '/')))
? $customPath
: __DIR__.$stub;
}

/**
Expand Down
1 change: 1 addition & 0 deletions src/Illuminate/Foundation/Console/StubPublishCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public function handle()
__DIR__.'/stubs/job.stub' => $stubsPath.'/job.stub',
__DIR__.'/stubs/model.pivot.stub' => $stubsPath.'/model.pivot.stub',
__DIR__.'/stubs/model.stub' => $stubsPath.'/model.stub',
__DIR__.'/stubs/request.stub' => $stubsPath.'/request.stub',
__DIR__.'/stubs/test.stub' => $stubsPath.'/test.stub',
__DIR__.'/stubs/test.unit.stub' => $stubsPath.'/test.unit.stub',
realpath(__DIR__.'/../../Database/Migrations/stubs/migration.create.stub') => $stubsPath.'/migration.create.stub',
Expand Down
4 changes: 2 additions & 2 deletions src/Illuminate/Foundation/Console/stubs/request.stub
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php

namespace DummyNamespace;
namespace {{ namespace }};

use Illuminate\Foundation\Http\FormRequest;

class DummyClass extends FormRequest
class {{ class }} extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
Expand Down

0 comments on commit f5b6f3b

Please sign in to comment.