-
Notifications
You must be signed in to change notification settings - Fork 2
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
Showing
4 changed files
with
90 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
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,60 @@ | ||
<?php | ||
|
||
namespace Creativeorange\LaravelStubs\Console\Make; | ||
|
||
use Creativeorange\LaravelStubs\Console\CustomGeneratorCommand; | ||
use Illuminate\Support\Str; | ||
use Symfony\Component\Console\Input\InputArgument; | ||
|
||
class MakeResponse extends CustomGeneratorCommand | ||
{ | ||
|
||
/** | ||
* The name and signature of the console command. | ||
* | ||
* @var string | ||
*/ | ||
protected $name = 'make:response'; | ||
|
||
/** | ||
* The console command description. | ||
* | ||
* @var string | ||
*/ | ||
protected $description = 'Create a new response'; | ||
|
||
protected $signature = 'make:response | ||
{name : The name of the response}'; | ||
|
||
protected $type = 'Response'; | ||
|
||
protected function getStub() | ||
{ | ||
return $this->resolveStubPath('/../stubs/response.stub'); | ||
} | ||
|
||
protected function getDefaultNamespace($rootNamespace) | ||
{ | ||
return (empty(config('laravel-stubs.make.response.namespace'))) | ||
? $rootNamespace | ||
: config('laravel-stubs.make.response.namespace'); | ||
} | ||
|
||
protected function getNameInput() | ||
{ | ||
$name = trim($this->argument('name')); | ||
|
||
$name = Str::endsWith($name, 'Response') | ||
? $name | ||
: $name . 'Response'; | ||
|
||
return $name; | ||
} | ||
|
||
protected function getArguments() | ||
{ | ||
return [ | ||
['name', InputArgument::REQUIRED, 'The name of the response'] | ||
]; | ||
} | ||
} |
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,21 @@ | ||
<?php | ||
|
||
namespace DummyNamespace; | ||
|
||
use Illuminate\Contracts\Support\Responsable; | ||
|
||
class DummyClass implements Responsable | ||
{ | ||
|
||
/** | ||
* Create an HTTP response that represents the object. | ||
* | ||
* @param \Illuminate\Http\Request $request | ||
* @return \Symfony\Component\HttpFoundation\Response | ||
*/ | ||
public function toResponse($request) | ||
{ | ||
return \response(); | ||
} | ||
|
||
} |