File tree Expand file tree Collapse file tree 4 files changed +90
-0
lines changed
Expand file tree Collapse file tree 4 files changed +90
-0
lines changed Original file line number Diff line number Diff line change 6565 'interface ' => [
6666 'namespace ' => '\App\Interfaces '
6767 ],
68+ /**
69+ * make:response
70+ *
71+ * Allows you to change the namespace (and so the folder) where the response will be stored
72+ */
73+ 'response ' => [
74+ 'namespace ' => '\App\Http\Responses '
75+ ],
6876 /**
6977 * make:scope
7078 *
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Creativeorange \LaravelStubs \Console \Make ;
4+
5+ use Creativeorange \LaravelStubs \Console \CustomGeneratorCommand ;
6+ use Illuminate \Support \Str ;
7+ use Symfony \Component \Console \Input \InputArgument ;
8+
9+ class MakeResponse extends CustomGeneratorCommand
10+ {
11+
12+ /**
13+ * The name and signature of the console command.
14+ *
15+ * @var string
16+ */
17+ protected $ name = 'make:response ' ;
18+
19+ /**
20+ * The console command description.
21+ *
22+ * @var string
23+ */
24+ protected $ description = 'Create a new response ' ;
25+
26+ protected $ signature = 'make:response
27+ {name : The name of the response} ' ;
28+
29+ protected $ type = 'Response ' ;
30+
31+ protected function getStub ()
32+ {
33+ return $ this ->resolveStubPath ('/../stubs/response.stub ' );
34+ }
35+
36+ protected function getDefaultNamespace ($ rootNamespace )
37+ {
38+ return (empty (config ('laravel-stubs.make.response.namespace ' )))
39+ ? $ rootNamespace
40+ : config ('laravel-stubs.make.response.namespace ' );
41+ }
42+
43+ protected function getNameInput ()
44+ {
45+ $ name = trim ($ this ->argument ('name ' ));
46+
47+ $ name = Str::endsWith ($ name , 'Response ' )
48+ ? $ name
49+ : $ name . 'Response ' ;
50+
51+ return $ name ;
52+ }
53+
54+ protected function getArguments ()
55+ {
56+ return [
57+ ['name ' , InputArgument::REQUIRED , 'The name of the response ' ]
58+ ];
59+ }
60+ }
Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ public function boot()
2323 Console \Make \MakeViewComposer::class,
2424 Console \Make \MakeFacade::class,
2525 Console \Make \MakeHelper::class,
26+ Console \Make \MakeResponse::class,
2627 /** Patch */
2728 Console \Patch::class,
2829 /** Publish */
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace DummyNamespace;
4+
5+ use Illuminate\Contracts\Support\Responsable;
6+
7+ class DummyClass implements Responsable
8+ {
9+
10+ /**
11+ * Create an HTTP response that represents the object.
12+ *
13+ * @param \Illuminate\Http\Request $request
14+ * @return \Symfony\Component\HttpFoundation\Response
15+ */
16+ public function toResponse($request)
17+ {
18+ return \response();
19+ }
20+
21+ }
You can’t perform that action at this time.
0 commit comments