@@ -15,37 +15,37 @@ discard block |
||
15 | 15 | '{{dataDefinition}}' => $this->getDataDefinition(), |
16 | 16 | '{{foreignData}}' => $this->getForeignData() |
17 | 17 | ]); |
18 | - $fullFilePath = $this->getPath("database/factories/") . $this->module->getModelName() . "Factory.php"; |
|
18 | + $fullFilePath = $this->getPath("database/factories/").$this->module->getModelName()."Factory.php"; |
|
19 | 19 | file_put_contents($fullFilePath, $modelTemplate); |
20 | - $generatedFiles[] = $fullFilePath; |
|
20 | + $generatedFiles[] = $fullFilePath; |
|
21 | 21 | |
22 | 22 | $modelTemplate = $this->buildTemplate('Seeder', [ |
23 | 23 | '{{modelName}}' => $this->module->getModelName(), |
24 | 24 | '{{usedModels}}' => $this->getUsedModels() |
25 | 25 | ]); |
26 | - $fullFilePath = $this->getPath("database/seeds/") . $this->module->getModelName() . "Seeder.php"; |
|
26 | + $fullFilePath = $this->getPath("database/seeds/").$this->module->getModelName()."Seeder.php"; |
|
27 | 27 | file_put_contents($fullFilePath, $modelTemplate); |
28 | - $generatedFiles[] = $fullFilePath; |
|
28 | + $generatedFiles[] = $fullFilePath; |
|
29 | 29 | |
30 | 30 | return $generatedFiles; |
31 | 31 | } |
32 | 32 | |
33 | - protected function getUsedModels(){ |
|
33 | + protected function getUsedModels() { |
|
34 | 34 | $foreignModels = $this->module->getForeignColumns(); |
35 | 35 | $namespace = "App\\Models\\"; |
36 | - $usedModels = "use " . $namespace . $this->module->getModelName() . ";"; |
|
36 | + $usedModels = "use ".$namespace.$this->module->getModelName().";"; |
|
37 | 37 | |
38 | 38 | foreach ($foreignModels as $models) { |
39 | - foreach($models as $column => $module){ |
|
39 | + foreach ($models as $column => $module) { |
|
40 | 40 | $namespace = ($module == 'users' && class_exists('App\\User')) ? "App\\" : "App\\Models\\"; |
41 | - $class = $namespace . $this->moduleToModelName($module); |
|
42 | - $usedModels .= PHP_EOL . "use " . $class . ";"; |
|
41 | + $class = $namespace.$this->moduleToModelName($module); |
|
42 | + $usedModels .= PHP_EOL."use ".$class.";"; |
|
43 | 43 | } |
44 | 44 | } |
45 | 45 | return $usedModels; |
46 | 46 | } |
47 | 47 | |
48 | - protected function getDataDefinition(){ |
|
48 | + protected function getDataDefinition() { |
|
49 | 49 | $specialTypesToDefinition = [ |
50 | 50 | 'title' => 'realText(50)', |
51 | 51 | 'firstname' => 'firstname', |
@@ -80,22 +80,22 @@ discard block |
||
80 | 80 | |
81 | 81 | $dataDefinition = ""; |
82 | 82 | foreach ($this->module->getNativeData() as $columns) { |
83 | - foreach($columns as $column => $type){ |
|
83 | + foreach ($columns as $column => $type) { |
|
84 | 84 | $specialTypes = array_keys($specialTypesToDefinition); |
85 | - if(in_array($column,$specialTypes)){ |
|
86 | - $dataDefinition .= $this->getTabs(2) . "'{$column}'" . " => " . '$faker->' . $specialTypesToDefinition[$column]; |
|
87 | - }else{ |
|
88 | - $dataDefinition .= $this->getTabs(2) . "'{$column}'" . " => " . '$faker->' . $typeToDefinition[$type]; |
|
85 | + if (in_array($column, $specialTypes)) { |
|
86 | + $dataDefinition .= $this->getTabs(2)."'{$column}'"." => ".'$faker->'.$specialTypesToDefinition[$column]; |
|
87 | + } else { |
|
88 | + $dataDefinition .= $this->getTabs(2)."'{$column}'"." => ".'$faker->'.$typeToDefinition[$type]; |
|
89 | 89 | } |
90 | 90 | |
91 | - if($column != last($columns)) |
|
92 | - $dataDefinition .= "," . PHP_EOL; |
|
91 | + if ($column != last($columns)) |
|
92 | + $dataDefinition .= ",".PHP_EOL; |
|
93 | 93 | } |
94 | 94 | } |
95 | 95 | return $dataDefinition; |
96 | 96 | } |
97 | 97 | |
98 | - protected function getForeignData(){ |
|
98 | + protected function getForeignData() { |
|
99 | 99 | $columns = $this->module->getForeignColumns('parent'); |
100 | 100 | |
101 | 101 | $foreignData = ""; |
@@ -107,8 +107,8 @@ discard block |
||
107 | 107 | '{{parentModel}}' => ucfirst(camel_case(str_singular($parent))) |
108 | 108 | ]); |
109 | 109 | |
110 | - if($column != last($columns)) |
|
111 | - $foreignData .= "," . PHP_EOL; |
|
110 | + if ($column != last($columns)) |
|
111 | + $foreignData .= ",".PHP_EOL; |
|
112 | 112 | } |
113 | 113 | } |
114 | 114 |