@@ -27,6 +27,13 @@ class Create extends ConsoleController
2727 */
2828 private $ fileExtention = '.php ' ;
2929
30+ /**
31+ * Set Namespace variable
32+ *
33+ * @var string
34+ */
35+ private $ namespace = '' ;
36+
3037 /**
3138 * Config variable
3239 *
@@ -239,6 +246,10 @@ private function createFile($filePath, $fileType, $stubType = '')
239246
240247 $ contents = ($ stubType === $ this ->view ) ? '' : "<?php \n\n" ;
241248
249+ if (!empty ($ this ->namespace )) {
250+ $ contents .= "namespace " . $ this ->namespace . "; \n\n" ;
251+ }
252+
242253 $ fileContent = $ this ->fileContent ($ fileType , $ className , $ stubType );
243254 $ contents .= $ fileContent ;
244255
@@ -901,6 +912,49 @@ public function createNonModuleController($controllerName = '', $addController =
901912 }
902913 }
903914
915+ /**
916+ * Create A Non Module Model
917+ *
918+ * @param string $modelName
919+ * @param string $modelType
920+ * @param string $removeModel
921+ * @param string $location
922+ * @return void
923+ */
924+ public function createNonModuleModel ($ modelName = '' , $ modelType = '--easy ' , $ removeModel = '' , $ location = 'App/Models ' )
925+ {
926+
927+ $ created = '' ;
928+ $ namespace = 'App\Models ' ;
929+ $ modelName = ucwords ($ modelName );
930+
931+ $ this ->model = 'Models ' ;
932+ $ this ->namespace = $ namespace ;
933+ $ modelDirectory = $ this ->createAppRootDirectory ($ this ->model );
934+
935+ if ($ removeModel == '--remove-model ' ) {
936+ $ modelName = $ modelName ;
937+ } else {
938+ $ modelName = Inflector::singularize ($ modelName ) . 'Model ' ;
939+ }
940+
941+ if (file_exists ($ modelDirectory . DS . $ modelName . $ this ->fileExtention )) {
942+ $ this ->failureOutput (ucfirst ($ modelName ) . " exists already in the " . $ location . " directory " );
943+ return ;
944+ }
945+
946+ if ($ modelDirectory && is_dir ($ modelDirectory )) {
947+ $ filePath = $ modelDirectory . DS . $ modelName ;
948+ $ modelType = str_replace ('- ' , '' , $ modelType );
949+ $ created = $ this ->createFile ($ filePath , strtolower ($ modelType . '_ ' ) . 'model ' , $ this ->model );
950+ }
951+
952+ if ($ created ) {
953+ $ this ->successOutput (ucfirst ($ modelName ) . " " .ucfirst ($ modelType ) . " Model created successfully " );
954+ return ;
955+ }
956+ }
957+
904958 /**
905959 * Create Model
906960 *
0 commit comments