@@ -51,7 +51,7 @@ class CreateControllerCommand extends GeneratorCommand
5151 */
5252 protected function getStub ()
5353 {
54- return $ this ->getStubByName ('controller ' , $ this ->getTemplateName () );
54+ return $ this ->getStubByName ('controller ' , $ this ->getTemplateName ());
5555 }
5656
5757 /**
@@ -68,8 +68,7 @@ protected function buildClass($name)
6868
6969 $ formRequestName = 'Request ' ;
7070
71- if ($ input ->formRequest )
72- {
71+ if ($ input ->formRequest ) {
7372 $ stub = $ this ->getStubContent ('controller-with-form-request ' , $ input ->template );
7473 $ formRequestName = $ input ->formRequestName ;
7574 $ this ->makeFormRequest ($ input );
@@ -100,8 +99,7 @@ protected function buildClass($name)
10099 */
101100 protected function getUploadFileMethod (array $ fields )
102101 {
103- if ($ this ->isContainfile ($ fields ))
104- {
102+ if ($ this ->isContainfile ($ fields )) {
105103 return $ this ->getStubContent ('controller-upload-method ' , $ this ->getTemplateName ());
106104 }
107105
@@ -129,7 +127,7 @@ protected function getRequestsNamespace()
129127 */
130128 protected function isContainMultipleAnswers (array $ fields )
131129 {
132- $ filtered = array_filter ($ fields , function ($ field ){
130+ $ filtered = array_filter ($ fields , function ($ field ) {
133131 return $ field ->isMultipleAnswers ;
134132 });
135133
@@ -145,7 +143,7 @@ protected function isContainMultipleAnswers(array $fields)
145143 */
146144 protected function makeFormRequest ($ input )
147145 {
148- $ this ->callSilent ('create:form-request ' ,
146+ $ this ->callSilent ('create:form-request ' ,
149147 [
150148 'class-name ' => $ input ->formRequestName ,
151149 '--fields ' => $ input ->fields ,
@@ -169,7 +167,7 @@ protected function getModelFullName($path, $name)
169167 {
170168 $ final = !empty ($ path ) ? $ this ->getModelsPath () . Helpers::getPathWithSlash ($ path ) : $ this ->getModelsPath ();
171169
172- return Helpers::convertSlashToBackslash ($ final . ucfirst ( $ name) );
170+ return Helpers::convertSlashToBackslash ($ final . $ name );
173171 }
174172
175173 /**
@@ -180,7 +178,9 @@ protected function getModelFullName($path, $name)
180178 protected function getCommandInput ()
181179 {
182180 $ controllerName = trim ($ this ->argument ('controller-name ' ));
183- $ modelName = strtolower (trim ($ this ->option ('model-name ' )) ?: str_singular (Helpers::removePostFixWith ($ controllerName , 'Controller ' )));
181+ $ plainControllerName = str_singular (Helpers::removePostFixWith ($ controllerName , 'Controller ' ));
182+
183+ $ modelName = trim ($ this ->option ('model-name ' )) ?: $ plainControllerName ;
184184 $ viewDirectory = trim ($ this ->option ('views-directory ' ));
185185 $ prefix = trim ($ this ->option ('routes-prefix ' ));
186186 $ perPage = intval ($ this ->option ('models-per-page ' ));
@@ -190,11 +190,11 @@ protected function getCommandInput()
190190 $ formRequest = $ this ->option ('with-form-request ' );
191191 $ force = $ this ->option ('force ' );
192192 $ modelDirectory = trim ($ this ->option ('model-directory ' ));
193- $ formRequestName = ucfirst ( $ modelName ) . 'FormRequest ' ;
193+ $ formRequestName = $ plainControllerName . 'FormRequest ' ;
194194 $ template = $ this ->getTemplateName ();
195195
196- return (object ) compact ('viewDirectory ' ,'viewName ' ,'modelName ' ,'prefix ' ,'perPage ' ,'fileSnippet ' ,'modelDirectory ' ,
197- 'langFile ' ,'fields ' ,'formRequest ' ,'formRequestName ' ,'force ' ,'fieldsFile ' ,'template ' );
196+ return (object ) compact ('viewDirectory ' , 'viewName ' , 'modelName ' , 'prefix ' , 'perPage ' , 'fileSnippet ' , 'modelDirectory ' ,
197+ 'langFile ' , 'fields ' , 'formRequest ' , 'formRequestName ' , 'force ' , 'fieldsFile ' , 'template ' );
198198 }
199199
200200 /**
@@ -328,8 +328,7 @@ public function getNameInput()
328328 $ path = $ this ->getControllersPath ();
329329 $ directory = trim ($ this ->option ('controller-directory ' ));
330330
331- if (!empty ($ directory ))
332- {
331+ if (!empty ($ directory )) {
333332 $ path .= Helpers::getPathWithSlash ($ directory );
334333 }
335334
@@ -347,16 +346,13 @@ protected function getFileReadySnippet(array $fields)
347346 {
348347 $ code = '' ;
349348
350- foreach ($ fields as $ field )
351- {
352- if ($ field ->isFile ())
353- {
349+ foreach ($ fields as $ field ) {
350+ if ($ field ->isFile ()) {
354351 $ code = ($ code ) ?: '$this ' ;
355352 $ code .= sprintf ("->uploadFile('%s', \$data) " , $ field ->name );
356353 }
357354 }
358355
359356 return $ code != '' ? $ code . '; ' : $ code ;
360357 }
361-
362358}
0 commit comments