@@ -11,23 +11,23 @@ |
||
11 | 11 | |
12 | 12 | $generatedFiles = []; |
13 | 13 | foreach ($viewsToBeGenerated as $view) { |
14 | - $viewTemplate = $this->buildTemplate('Views/' . $view, [ |
|
14 | + $viewTemplate = $this->buildTemplate('Views/'.$view, [ |
|
15 | 15 | '{{modelNameSingularLowercase}}' => $this->module->getModelNameSingularLowercase(), |
16 | 16 | '{{modelNamePlural}}' => $this->module->getModelNamePlural(), |
17 | 17 | '{{moduleName}}' => $this->module->getModuleName() |
18 | 18 | ]); |
19 | 19 | |
20 | - $fullFilePath = $this->getPath("resources/views/" . $this->module->getModuleName()) . "/{$view}.blade.php"; |
|
20 | + $fullFilePath = $this->getPath("resources/views/".$this->module->getModuleName())."/{$view}.blade.php"; |
|
21 | 21 | file_put_contents($fullFilePath, $viewTemplate); |
22 | - $generatedFiles[] = $fullFilePath; |
|
22 | + $generatedFiles[] = $fullFilePath; |
|
23 | 23 | } |
24 | 24 | |
25 | - $layoutPath = $this->getPath("resources/views/laragen/layouts/") . "app.blade.php"; |
|
26 | - if(!file_exists($layoutPath)){ |
|
25 | + $layoutPath = $this->getPath("resources/views/laragen/layouts/")."app.blade.php"; |
|
26 | + if (!file_exists($layoutPath)) { |
|
27 | 27 | |
28 | 28 | $viewTemplate = $this->buildTemplate('Views/layouts/app', []); |
29 | 29 | file_put_contents($layoutPath, $viewTemplate); |
30 | - $generatedFiles[] = $layoutPath; |
|
30 | + $generatedFiles[] = $layoutPath; |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | return $generatedFiles; |
@@ -47,10 +47,11 @@ |
||
47 | 47 | $itemGenerator = new $generator($module); |
48 | 48 | $returnedFiles = $itemGenerator->generate(); |
49 | 49 | |
50 | - if (!is_array($returnedFiles)) |
|
51 | - $generatedFiles[] = $returnedFiles; |
|
52 | - else |
|
53 | - $generatedFiles = array_merge($generatedFiles, $returnedFiles); |
|
50 | + if (!is_array($returnedFiles)) { |
|
51 | + $generatedFiles[] = $returnedFiles; |
|
52 | + } else { |
|
53 | + $generatedFiles = array_merge($generatedFiles, $returnedFiles); |
|
54 | + } |
|
54 | 55 | |
55 | 56 | $bar->advance(); |
56 | 57 | } |
@@ -52,8 +52,12 @@ |
||
52 | 52 | $schema = $this->processSpecialSchema(); |
53 | 53 | } else { |
54 | 54 | foreach ($this->optionArray as $option) { |
55 | - if ($option == self::COLUMN_UNIQUE) $this->hasUnique(); |
|
56 | - if (is_numeric($option) && $option <= 2048) $this->hasSize((int) $option); |
|
55 | + if ($option == self::COLUMN_UNIQUE) { |
|
56 | + $this->hasUnique(); |
|
57 | + } |
|
58 | + if (is_numeric($option) && $option <= 2048) { |
|
59 | + $this->hasSize((int) $option); |
|
60 | + } |
|
57 | 61 | } |
58 | 62 | |
59 | 63 | $schema = '$table->'.$this->getType()."('{$this->column}'"; |
@@ -55,10 +55,11 @@ |
||
55 | 55 | |
56 | 56 | public function getForeignColumns($type = 'all') |
57 | 57 | { |
58 | - if (is_array($type)) |
|
59 | - $types = $type; |
|
60 | - else |
|
61 | - $types = ($type == "all") ? ['parent', 'related'] : [$type]; |
|
58 | + if (is_array($type)) { |
|
59 | + $types = $type; |
|
60 | + } else { |
|
61 | + $types = ($type == "all") ? ['parent', 'related'] : [$type]; |
|
62 | + } |
|
62 | 63 | |
63 | 64 | $data = []; |
64 | 65 | foreach ($this->data as $column => $optionString) { |
@@ -33,8 +33,8 @@ discard block |
||
33 | 33 | $this->insertIntoFile( |
34 | 34 | $webRouteFile, |
35 | 35 | "<?php\n", |
36 | - "use App\\Http\\Controllers\\".$this->module->getModelName()."Controller;\n" |
|
37 | - ); |
|
36 | + "use App\\Http\\Controllers\\".$this->module->getModelName()."Controller;\n" |
|
37 | + ); |
|
38 | 38 | |
39 | 39 | $this->insertIntoFile( |
40 | 40 | $webRouteFile, |
@@ -42,13 +42,13 @@ discard block |
||
42 | 42 | "\n".$this->getTabs(1)."Route::resource('".$this->module->getModuleName()."', ".$this->module->getModelName()."Controller::class);" |
43 | 43 | ); |
44 | 44 | |
45 | - $generatedFiles[] = $webRouteFile; |
|
45 | + $generatedFiles[] = $webRouteFile; |
|
46 | 46 | |
47 | 47 | $this->insertIntoFile( |
48 | 48 | $backendWebRouteFile, |
49 | 49 | "<?php\n", |
50 | - "use App\\Http\\Controllers\\".$this->module->getModelName()."Controller;\n" |
|
51 | - ); |
|
50 | + "use App\\Http\\Controllers\\".$this->module->getModelName()."Controller;\n" |
|
51 | + ); |
|
52 | 52 | |
53 | 53 | $this->insertIntoFile( |
54 | 54 | $backendWebRouteFile, |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | |
39 | 39 | $this->insertIntoFile( |
40 | 40 | $webRouteFile, |
41 | - "/" . "* Insert your routes here */", |
|
41 | + "/"."* Insert your routes here */", |
|
42 | 42 | "\n".$this->getTabs(1)."Route::resource('".$this->module->getModuleName()."', ".$this->module->getModelName()."Controller::class);" |
43 | 43 | ); |
44 | 44 | |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | |
53 | 53 | $this->insertIntoFile( |
54 | 54 | $backendWebRouteFile, |
55 | - "/" . "* Insert your routes here */", |
|
55 | + "/"."* Insert your routes here */", |
|
56 | 56 | "\n".$this->getTabs(1)."Route::resource('".$this->module->getModuleName()."', ".$this->module->getModelName()."Controller::class);" |
57 | 57 | ); |
58 | 58 |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | file_put_contents($fullFilePath, $factoryTemplate); |
24 | 24 | $generatedFiles[] = $fullFilePath; |
25 | 25 | |
26 | - $laragenSeederFile = (self::$initializeFlag++ == 0) ? $this->initializeFile($this->getPath("database/seeds/")."LaragenSeeder.php", 'Seeder') : $this->getPath("database/seeds/")."LaragenSeeder.php"; |
|
26 | + $laragenSeederFile = (self::$initializeFlag++ == 0) ? $this->initializeFile($this->getPath("database/seeds/")."LaragenSeeder.php", 'Seeder') : $this->getPath("database/seeds/")."LaragenSeeder.php"; |
|
27 | 27 | |
28 | 28 | $this->insertIntoFile( |
29 | 29 | $laragenSeederFile, |
@@ -93,23 +93,23 @@ discard block |
||
93 | 93 | |
94 | 94 | $dataDefinition = ""; |
95 | 95 | foreach ($this->module->getNativeData() as $columns) { |
96 | - foreach($columns as $column => $type){ |
|
96 | + foreach ($columns as $column => $type) { |
|
97 | 97 | $specialTypes = array_keys($specialTypesToDefinition); |
98 | - if(in_array($column,$specialTypes)){ |
|
99 | - $dataDefinition .= $this->getTabs(2) . "'{$column}'" . " => " . '$faker->' . $specialTypesToDefinition[$column]; |
|
100 | - } else{ |
|
101 | - $dataDefinition .= $this->getTabs(2) . "'{$column}'" . " => " . '$faker->' . $typeToDefinition[$type]; |
|
98 | + if (in_array($column, $specialTypes)) { |
|
99 | + $dataDefinition .= $this->getTabs(2)."'{$column}'"." => ".'$faker->'.$specialTypesToDefinition[$column]; |
|
100 | + } else { |
|
101 | + $dataDefinition .= $this->getTabs(2)."'{$column}'"." => ".'$faker->'.$typeToDefinition[$type]; |
|
102 | 102 | } |
103 | 103 | |
104 | - if($column != last($columns)) { |
|
105 | - $dataDefinition .= "," . PHP_EOL; |
|
104 | + if ($column != last($columns)) { |
|
105 | + $dataDefinition .= ",".PHP_EOL; |
|
106 | 106 | } |
107 | 107 | } |
108 | 108 | } |
109 | 109 | return $dataDefinition; |
110 | 110 | } |
111 | 111 | |
112 | - protected function getForeignData(){ |
|
112 | + protected function getForeignData() { |
|
113 | 113 | $columns = $this->module->getForeignColumns('parent'); |
114 | 114 | |
115 | 115 | $foreignData = ""; |
@@ -121,8 +121,8 @@ discard block |
||
121 | 121 | '{{parentModel}}' => ucfirst(camel_case(str_singular($parent))) |
122 | 122 | ]); |
123 | 123 | |
124 | - if($column != last($columns)) { |
|
125 | - $foreignData .= "," . PHP_EOL; |
|
124 | + if ($column != last($columns)) { |
|
125 | + $foreignData .= ",".PHP_EOL; |
|
126 | 126 | } |
127 | 127 | } |
128 | 128 | } |
@@ -51,10 +51,10 @@ discard block |
||
51 | 51 | } |
52 | 52 | |
53 | 53 | public function initializeFile($fullFilePath, $stub, $initializeWithText = false) { |
54 | - if(file_exists($fullFilePath)){ |
|
54 | + if (file_exists($fullFilePath)) { |
|
55 | 55 | $this->fileSystem->remove($fullFilePath); |
56 | 56 | } |
57 | - $seederTemplate = ($initializeWithText===false) ? $this->buildTemplate($stub) : $initializeWithText; |
|
57 | + $seederTemplate = ($initializeWithText === false) ? $this->buildTemplate($stub) : $initializeWithText; |
|
58 | 58 | $this->fileSystem->dumpFile($fullFilePath, $seederTemplate); |
59 | 59 | return $fullFilePath; |
60 | 60 | } |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | } |
77 | 77 | |
78 | 78 | public function insertIntoFile($file_path, $insert_marker, $text, $after = true) { |
79 | - $contents = str_replace("\r",'', file_get_contents($file_path)); |
|
79 | + $contents = str_replace("\r", '', file_get_contents($file_path)); |
|
80 | 80 | $new_contents = ($after) ? str_replace($insert_marker, $insert_marker.$text, $contents) : str_replace($insert_marker, $text.$insert_marker, $contents); |
81 | 81 | $this->fileSystem->dumpFile($file_path, $new_contents); |
82 | 82 | } |
@@ -39,8 +39,9 @@ |
||
39 | 39 | { |
40 | 40 | $dir = base_path($path); |
41 | 41 | |
42 | - if (!is_dir($dir)) |
|
43 | - $this->fileSystem->mkdir($dir, 0755); |
|
42 | + if (!is_dir($dir)) { |
|
43 | + $this->fileSystem->mkdir($dir, 0755); |
|
44 | + } |
|
44 | 45 | |
45 | 46 | return $dir; |
46 | 47 | } |
@@ -5,19 +5,19 @@ |
||
5 | 5 | |
6 | 6 | class FileSystem extends SymphonyFilesystem |
7 | 7 | { |
8 | - public function clone($src, $dest){ |
|
9 | - $src = $this->getFullSourcePath($src); |
|
8 | + public function clone($src, $dest){ |
|
9 | + $src = $this->getFullSourcePath($src); |
|
10 | 10 | |
11 | - $dest = base_path($dest); |
|
11 | + $dest = base_path($dest); |
|
12 | 12 | |
13 | - if (is_dir($src)) { |
|
14 | - $this->mirror($src, $dest."/".basename($src)); |
|
15 | - }else{ |
|
16 | - $this->copy($src, $dest); |
|
17 | - } |
|
18 | - } |
|
13 | + if (is_dir($src)) { |
|
14 | + $this->mirror($src, $dest."/".basename($src)); |
|
15 | + }else{ |
|
16 | + $this->copy($src, $dest); |
|
17 | + } |
|
18 | + } |
|
19 | 19 | |
20 | - public function getFullSourcePath($path){ |
|
21 | - return realpath(__DIR__ . "/../resources/" . $path); |
|
22 | - } |
|
20 | + public function getFullSourcePath($path){ |
|
21 | + return realpath(__DIR__ . "/../resources/" . $path); |
|
22 | + } |
|
23 | 23 | } |
@@ -12,12 +12,12 @@ |
||
12 | 12 | |
13 | 13 | if (is_dir($src)) { |
14 | 14 | $this->mirror($src, $dest."/".basename($src)); |
15 | - }else{ |
|
15 | + } else { |
|
16 | 16 | $this->copy($src, $dest); |
17 | 17 | } |
18 | 18 | } |
19 | 19 | |
20 | - public function getFullSourcePath($path){ |
|
21 | - return realpath(__DIR__ . "/../resources/" . $path); |
|
20 | + public function getFullSourcePath($path) { |
|
21 | + return realpath(__DIR__."/../resources/".$path); |
|
22 | 22 | } |
23 | 23 | } |
@@ -12,7 +12,7 @@ |
||
12 | 12 | |
13 | 13 | if (is_dir($src)) { |
14 | 14 | $this->mirror($src, $dest."/".basename($src)); |
15 | - }else{ |
|
15 | + } else{ |
|
16 | 16 | $this->copy($src, $dest); |
17 | 17 | } |
18 | 18 | } |