@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | file_put_contents($fullFilePath, $modelTemplate); |
22 | 22 | $generatedFiles[] = $fullFilePath; |
23 | 23 | |
24 | - foreach($this->module->getFilteredColumns('hasPivot') as $type){ |
|
24 | + foreach ($this->module->getFilteredColumns('hasPivot') as $type) { |
|
25 | 25 | $typeTemplate = $this->buildTemplate('common/Models/Pivot', [ |
26 | 26 | '{{pivotName}}' => $type->getPivot(), |
27 | 27 | '{{massAssignables}}' => implode("', '", $type->getTypeColumns()), |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | $generatedFiles[] = $fullFilePath; |
33 | 33 | } |
34 | 34 | |
35 | - foreach($this->module->getFilteredColumns(['hasModel', 'hasOptions']) as $type){ |
|
35 | + foreach ($this->module->getFilteredColumns(['hasModel', 'hasOptions']) as $type) { |
|
36 | 36 | $pivotModel = Str::singular($type->getPivot()); |
37 | 37 | $typeTemplate = $this->buildTemplate('common/Models/Model', [ |
38 | 38 | '{{modelName}}' => $pivotModel, |
@@ -66,10 +66,10 @@ discard block |
||
66 | 66 | protected function getUsedModels($pivotModel = false) { |
67 | 67 | $usedModels = ""; |
68 | 68 | $classes = []; |
69 | - foreach($this->module->getFilteredColumns(['hasSingleRelation', 'hasPivot', 'hasModel']) as $type){ |
|
69 | + foreach ($this->module->getFilteredColumns(['hasSingleRelation', 'hasPivot', 'hasModel']) as $type) { |
|
70 | 70 | $model = $type->getRelatedModel(); |
71 | 71 | $class = ($model == 'User') ? config('laragen.options.user_model') : "App\\Models\\".$model; |
72 | - if(in_array($class, $classes) || $model == $this->module->getModelName() || $model == $pivotModel){ |
|
72 | + if (in_array($class, $classes) || $model == $this->module->getModelName() || $model == $pivotModel) { |
|
73 | 73 | continue; |
74 | 74 | } |
75 | 75 | $classes[] = $class; |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | protected function getForeignMethods() |
82 | 82 | { |
83 | 83 | $foreignMethods = ""; |
84 | - foreach($this->module->getFilteredColumns(['hasPivot', 'hasSingleRelation', 'hasModel']) as $type){ |
|
84 | + foreach ($this->module->getFilteredColumns(['hasPivot', 'hasSingleRelation', 'hasModel']) as $type) { |
|
85 | 85 | $stub = $type->getStub('foreignMethod') ?: 'common/Models/fragments/hasOne'; |
86 | 86 | $foreignMethods .= $this->buildTemplate($stub, [ |
87 | 87 | '{{columnName}}' => $type->getColumn(), |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | '{{relatedModel}}' => $type->getRelatedModel(), |
90 | 90 | '{{table}}' => $type->getPivotTable(), |
91 | 91 | '{{parentModel}}' => $type->getParentModel(), |
92 | - '{{parentId}}' => $type->getParentModelLowercase() . "_id", |
|
92 | + '{{parentId}}' => $type->getParentModelLowercase()."_id", |
|
93 | 93 | '{{childId}}' => $type->getChildKey(), |
94 | 94 | ]); |
95 | 95 | } |
@@ -11,11 +11,11 @@ discard block |
||
11 | 11 | |
12 | 12 | public function generate() |
13 | 13 | { |
14 | - if(self::$counter==0){ |
|
14 | + if (self::$counter == 0) { |
|
15 | 15 | $existingMigrationFiles = is_dir(database_path('migrations/laragen/')) ? scandir(database_path('migrations/laragen/')) : []; |
16 | 16 | |
17 | 17 | foreach ($existingMigrationFiles as $file) { |
18 | - $file = database_path("migrations/laragen") . "/" . $file; |
|
18 | + $file = database_path("migrations/laragen")."/".$file; |
|
19 | 19 | if (is_file($file)) |
20 | 20 | unlink($file); |
21 | 21 | } |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | |
24 | 24 | $generatedFiles = []; |
25 | 25 | |
26 | - foreach($this->module->getFilteredColumns('needsTableInit') as $type){ |
|
26 | + foreach ($this->module->getFilteredColumns('needsTableInit') as $type) { |
|
27 | 27 | $migrationTemplate = $this->buildTemplate('common/migrations/pivot', [ |
28 | 28 | '{{pivotName}}' => $type->getMigrationPivot(), |
29 | 29 | '{{pivotTableName}}' => $type->getPivotTable(), |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | file_put_contents($fullFilePath, $migrationTemplate); |
47 | 47 | $generatedFiles[] = $fullFilePath; |
48 | 48 | |
49 | - foreach($this->module->getFilteredColumns(['hasPivot']) as $type){ |
|
49 | + foreach ($this->module->getFilteredColumns(['hasPivot']) as $type) { |
|
50 | 50 | $migrationTemplate = $this->buildTemplate('common/migrations/pivot', [ |
51 | 51 | '{{pivotName}}' => $type->getMigrationPivot(), |
52 | 52 | '{{pivotTableName}}' => $type->getPivotTable(), |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | { |
74 | 74 | $fileCounter = sprintf('%06d', (int) date('His') + ++self::$counter); |
75 | 75 | $filenamePrefix = date('Y_m_d_').$fileCounter."_"; |
76 | - $fileName = "create_". $related->getPivotTable()."_table.php"; |
|
76 | + $fileName = "create_".$related->getPivotTable()."_table.php"; |
|
77 | 77 | |
78 | 78 | return $this->getPath("database/migrations/laragen/").$filenamePrefix.$fileName; |
79 | 79 | } |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | { |
47 | 47 | $generatedFiles = []; |
48 | 48 | |
49 | - if($this::$initializeFlag == 0){ |
|
49 | + if ($this::$initializeFlag == 0) { |
|
50 | 50 | $laragen = app('laragen'); |
51 | 51 | $modules = $laragen->getModules(); |
52 | 52 | $permissions = []; |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | |
68 | 68 | $permissionsCode = ''; |
69 | 69 | foreach ($allPermissions as $permission) { |
70 | - $permissionsCode .= "Permission::create(['name' => '". $permission ."']);" . PHP_EOL. $this->getTabs(2); |
|
70 | + $permissionsCode .= "Permission::create(['name' => '".$permission."']);".PHP_EOL.$this->getTabs(2); |
|
71 | 71 | |
72 | 72 | } |
73 | 73 | |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | file_put_contents($fullFilePath, $factoryTemplate); |
94 | 94 | $generatedFiles[] = $fullFilePath; |
95 | 95 | |
96 | - foreach($this->module->getFilteredColumns(['hasPivot']) as $type){ |
|
96 | + foreach ($this->module->getFilteredColumns(['hasPivot']) as $type) { |
|
97 | 97 | $typeTemplate = $this->buildTemplate('common/Factories/Factory', [ |
98 | 98 | '{{modelName}}' => $type->getPivot(), |
99 | 99 | '{{usedModels}}' => $this->getUsedModels($type->getFilteredColumns('hasSingleRelation'), $type->getPivot()), |
@@ -118,10 +118,10 @@ discard block |
||
118 | 118 | |
119 | 119 | $classes = [$model]; |
120 | 120 | |
121 | - foreach($types as $type){ |
|
121 | + foreach ($types as $type) { |
|
122 | 122 | $model = $type->getRelatedModel(); |
123 | 123 | $class = ($model == 'User') ? config('laragen.options.user_model') : "App\\Models\\".$model; |
124 | - if(in_array($class, $classes)){ |
|
124 | + if (in_array($class, $classes)) { |
|
125 | 125 | continue; |
126 | 126 | } |
127 | 127 | $classes[] = $class; |
@@ -136,8 +136,7 @@ discard block |
||
136 | 136 | foreach ($columns as $type) { |
137 | 137 | $specialTypes = array_keys($this->specialTypesToDefinition); |
138 | 138 | $dataDefinition .= in_array($type->getColumn(), $specialTypes) ? |
139 | - $this->getTabs(2)."'{$type->getColumn()}'"." => ".'$faker->'.$this->specialTypesToDefinition[$type->getColumn()] : |
|
140 | - $this->getTabs(2)."'{$type->getColumn()}'"." => ".'$faker->'.$this->typeToDefinition[$type->getDataType()]; |
|
139 | + $this->getTabs(2)."'{$type->getColumn()}'"." => ".'$faker->'.$this->specialTypesToDefinition[$type->getColumn()] : $this->getTabs(2)."'{$type->getColumn()}'"." => ".'$faker->'.$this->typeToDefinition[$type->getDataType()]; |
|
141 | 140 | $dataDefinition .= ",".PHP_EOL; |
142 | 141 | } |
143 | 142 | return $dataDefinition; |
@@ -146,8 +145,8 @@ discard block |
||
146 | 145 | protected function getForeignData($types) { |
147 | 146 | $foreignData = ""; |
148 | 147 | |
149 | - foreach($types as $type){ |
|
150 | - if($type->hasSelfParent()) continue; |
|
148 | + foreach ($types as $type) { |
|
149 | + if ($type->hasSelfParent()) continue; |
|
151 | 150 | $foreignData .= $this->buildTemplate('common/Factories/fragments/options', [ |
152 | 151 | '{{parent}}' => $type->getColumnKey(), |
153 | 152 | '{{parentModel}}' => $type->getRelatedModel() |
@@ -174,7 +173,7 @@ discard block |
||
174 | 173 | false |
175 | 174 | ); |
176 | 175 | |
177 | - foreach($this->module->getFilteredColumns(['needsTableInit']) as $type){ |
|
176 | + foreach ($this->module->getFilteredColumns(['needsTableInit']) as $type) { |
|
178 | 177 | |
179 | 178 | $this->insertIntoFile( |
180 | 179 | $laragenSeederFile, |
@@ -183,14 +182,14 @@ discard block |
||
183 | 182 | false |
184 | 183 | ); |
185 | 184 | |
186 | - $seedData = PHP_EOL.$this->getTabs(2). "if(".$type->getPivot()."::all()->count()==0){"; |
|
187 | - $seedData .= PHP_EOL.$this->getTabs(3). "DB::table('".$type->getPivotTable()."')->insert(["; |
|
188 | - foreach($type->getDbData() as $title){ |
|
185 | + $seedData = PHP_EOL.$this->getTabs(2)."if(".$type->getPivot()."::all()->count()==0){"; |
|
186 | + $seedData .= PHP_EOL.$this->getTabs(3)."DB::table('".$type->getPivotTable()."')->insert(["; |
|
187 | + foreach ($type->getDbData() as $title) { |
|
189 | 188 | $seedData .= PHP_EOL.$this->getTabs(4); |
190 | - $seedData .= "['title' => '" . $title . "'],"; |
|
189 | + $seedData .= "['title' => '".$title."'],"; |
|
191 | 190 | } |
192 | - $seedData .= PHP_EOL.$this->getTabs(3). "]);"; |
|
193 | - $seedData .= PHP_EOL.$this->getTabs(2). "}"; |
|
191 | + $seedData .= PHP_EOL.$this->getTabs(3)."]);"; |
|
192 | + $seedData .= PHP_EOL.$this->getTabs(2)."}"; |
|
194 | 193 | |
195 | 194 | $this->insertIntoFile( |
196 | 195 | $laragenSeederFile, |
@@ -199,7 +198,7 @@ discard block |
||
199 | 198 | ); |
200 | 199 | } |
201 | 200 | |
202 | - foreach($this->module->getFilteredColumns(['hasPivot']) as $type){ |
|
201 | + foreach ($this->module->getFilteredColumns(['hasPivot']) as $type) { |
|
203 | 202 | |
204 | 203 | $this->insertIntoFile( |
205 | 204 | $laragenSeederFile, |
@@ -211,7 +210,7 @@ discard block |
||
211 | 210 | $this->insertIntoFile( |
212 | 211 | $laragenSeederFile, |
213 | 212 | "\n // End factories", |
214 | - "\n".$this->getTabs(2)."factory(".$type->getPivot()."::class, ".(int)config('laragen.options.seed_rows') * 2 .")->create();", |
|
213 | + "\n".$this->getTabs(2)."factory(".$type->getPivot()."::class, ".(int) config('laragen.options.seed_rows') * 2.")->create();", |
|
215 | 214 | false |
216 | 215 | ); |
217 | 216 | } |
@@ -63,7 +63,7 @@ |
||
63 | 63 | } |
64 | 64 | |
65 | 65 | public function getCleanPath($file) { |
66 | - return realpath(dirname($file)) . DIRECTORY_SEPARATOR . basename($file); |
|
66 | + return realpath(dirname($file)).DIRECTORY_SEPARATOR.basename($file); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | public function initializeFiles($fileMaps = []) { |
@@ -82,11 +82,11 @@ discard block |
||
82 | 82 | |
83 | 83 | protected function getForeignData() { |
84 | 84 | $foreignData = ""; |
85 | - $parents = $this->module->getFilteredColumns(['hasPivot','hasSingleRelation']); |
|
85 | + $parents = $this->module->getFilteredColumns(['hasPivot', 'hasSingleRelation']); |
|
86 | 86 | $columns = []; |
87 | 87 | foreach ($parents as $type) { |
88 | 88 | $column = $type->getRelatedModule(); |
89 | - if(!in_array($column, $columns)){ |
|
89 | + if (!in_array($column, $columns)) { |
|
90 | 90 | $foreignData .= "'".$column."' => ".$type->getRelatedModel()."::all(),".PHP_EOL.$this->getTabs(3); |
91 | 91 | $columns[] = $column; |
92 | 92 | } |
@@ -99,10 +99,10 @@ discard block |
||
99 | 99 | $usedModels = "use ".$namespace.$this->module->getModelName().";"; |
100 | 100 | |
101 | 101 | $classes = [$namespace.$this->module->getModelName()]; |
102 | - foreach($this->module->getFilteredColumns(['hasSingleRelation', 'hasPivot', 'hasModel']) as $type){ |
|
102 | + foreach ($this->module->getFilteredColumns(['hasSingleRelation', 'hasPivot', 'hasModel']) as $type) { |
|
103 | 103 | $model = $type->getRelatedModel(); |
104 | 104 | $class = ($model == 'User') ? config('laragen.options.user_model') : "App\\Models\\".$model; |
105 | - if(in_array($class, $classes)){ |
|
105 | + if (in_array($class, $classes)) { |
|
106 | 106 | continue; |
107 | 107 | } |
108 | 108 | $classes[] = $class; |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | $fileUploads .= $this->getTabs(3).'}'.PHP_EOL; |
76 | 76 | $fileUploads .= $this->getTabs(3).'$'.$this->module->getModelNameLowercase().'->'.$fileField->getColumn().'()->saveMany($'.$fileField->getColumn().');'.PHP_EOL; |
77 | 77 | |
78 | - }else{ |
|
78 | + } else { |
|
79 | 79 | $fileUploads .= $this->getTabs(3).'$uploadData = $this->uploader->'.$processMethod.'($request->input("'.$fileField->getColumn().'"), "'.$this->module->getModelNameLowercase().'");'.PHP_EOL; |
80 | 80 | $fileUploads .= $this->getTabs(3).'if (empty($uploadData["errors"])) {'.PHP_EOL; |
81 | 81 | $fileUploads .= $this->getTabs(4).'$updateData["'.$fileField->getColumn().'"] = $uploadData["filename"];'.PHP_EOL; |
@@ -88,11 +88,11 @@ discard block |
||
88 | 88 | |
89 | 89 | protected function getForeignData() { |
90 | 90 | $foreignData = ""; |
91 | - $parents = $this->module->getFilteredColumns(['hasPivot','hasSingleRelation']); |
|
91 | + $parents = $this->module->getFilteredColumns(['hasPivot', 'hasSingleRelation']); |
|
92 | 92 | $columns = []; |
93 | 93 | foreach ($parents as $type) { |
94 | 94 | $column = $type->getRelatedModule(); |
95 | - if(!in_array($column, $columns)){ |
|
95 | + if (!in_array($column, $columns)) { |
|
96 | 96 | $foreignData .= "'".$column."' => ".$type->getRelatedModel()."::all(),".PHP_EOL.$this->getTabs(3); |
97 | 97 | $columns[] = $column; |
98 | 98 | } |
@@ -105,10 +105,10 @@ discard block |
||
105 | 105 | $usedModels = "use ".$namespace.$this->module->getModelName().";"; |
106 | 106 | |
107 | 107 | $classes = [$namespace.$this->module->getModelName()]; |
108 | - foreach($this->module->getFilteredColumns(['hasSingleRelation', 'hasPivot', 'hasModel']) as $type){ |
|
108 | + foreach ($this->module->getFilteredColumns(['hasSingleRelation', 'hasPivot', 'hasModel']) as $type) { |
|
109 | 109 | $model = $type->getRelatedModel(); |
110 | 110 | $class = ($model == 'User') ? config('laragen.options.user_model') : "App\\Models\\".$model; |
111 | - if(in_array($class, $classes)){ |
|
111 | + if (in_array($class, $classes)) { |
|
112 | 112 | continue; |
113 | 113 | } |
114 | 114 | $classes[] = $class; |
@@ -9,9 +9,9 @@ discard block |
||
9 | 9 | protected static $initializeFlag = 0; |
10 | 10 | public function generate() |
11 | 11 | { |
12 | - $generatedFiles=[]; |
|
12 | + $generatedFiles = []; |
|
13 | 13 | |
14 | - if($this::$initializeFlag == 0){ |
|
14 | + if ($this::$initializeFlag == 0) { |
|
15 | 15 | $laragen = app('laragen'); |
16 | 16 | $modules = $laragen->getModules(); |
17 | 17 | $models = []; |
@@ -22,9 +22,9 @@ discard block |
||
22 | 22 | $modelsCode = ''; |
23 | 23 | $usedClasses = ''; |
24 | 24 | foreach ($models as $model) { |
25 | - $modelsCode .= $model ."::observe(". $model ."Observer::class);" . PHP_EOL. $this->getTabs(2); |
|
26 | - $usedClasses .= "use App\Observers\\". $model . "Observer;" . PHP_EOL; |
|
27 | - $usedClasses .= "use App\Models\\". $model . ";" . PHP_EOL; |
|
25 | + $modelsCode .= $model."::observe(".$model."Observer::class);".PHP_EOL.$this->getTabs(2); |
|
26 | + $usedClasses .= "use App\Observers\\".$model."Observer;".PHP_EOL; |
|
27 | + $usedClasses .= "use App\Models\\".$model.";".PHP_EOL; |
|
28 | 28 | } |
29 | 29 | |
30 | 30 | $observerProviderTemplate = $this->buildTemplate('common/LaragenObserverServiceProvider', [ |
@@ -61,10 +61,9 @@ discard block |
||
61 | 61 | foreach ($columns as $column) { |
62 | 62 | $headings .= |
63 | 63 | $simple ? |
64 | - "<th>" . $column->getDisplay() . "</th>" : |
|
65 | - "<th> |
|
66 | - <a href=\"{{ route('backend." . $this->module->getModuleName() . ".index') }}?sort=" . $column->getColumn() . "&sort_dir={{ request()->input('sort_dir')=='asc' ? 'desc' : 'asc' }}\">" . $column->getDisplay() . " |
|
67 | - @if(request()->input('sort')=='" . $column->getColumn() . "') |
|
64 | + "<th>".$column->getDisplay()."</th>" : "<th> |
|
65 | + <a href=\"{{ route('backend." . $this->module->getModuleName().".index') }}?sort=".$column->getColumn()."&sort_dir={{ request()->input('sort_dir')=='asc' ? 'desc' : 'asc' }}\">".$column->getDisplay()." |
|
66 | + @if(request()->input('sort')=='" . $column->getColumn()."') |
|
68 | 67 | {!! request()->input('sort_dir')=='asc' ? '<i class=\"fas fa-arrow-down\"></i>' : '<i class=\"fas fa-arrow-up\"></i>' !!} |
69 | 68 | @endif |
70 | 69 | </a> |
@@ -78,11 +77,11 @@ discard block |
||
78 | 77 | $tabs = $this->module->getTabTitles(); |
79 | 78 | $data = ""; |
80 | 79 | foreach ($tabs as $key => $tab) { |
81 | - $activeClass = ($key==0) ? 'active' : ''; |
|
80 | + $activeClass = ($key == 0) ? 'active' : ''; |
|
82 | 81 | $data .= '<li class="nav-item">'.PHP_EOL.$this->getTabs(7); |
83 | - $data .= '<a class="nav-link '. $activeClass .'" id="base-tab'.$key.'" data-toggle="tab" aria-controls="tab'.$key.'" href="#tab'.$key.'" aria-expanded="true">'.$tab. '</a>' . PHP_EOL . $this->getTabs(6); |
|
82 | + $data .= '<a class="nav-link '.$activeClass.'" id="base-tab'.$key.'" data-toggle="tab" aria-controls="tab'.$key.'" href="#tab'.$key.'" aria-expanded="true">'.$tab.'</a>'.PHP_EOL.$this->getTabs(6); |
|
84 | 83 | $data .= '</li>'; |
85 | - $data .= ($tab!==last($tabs)) ? PHP_EOL . $this->getTabs(6) : ''; |
|
84 | + $data .= ($tab !== last($tabs)) ? PHP_EOL . $this->getTabs(6) : ''; |
|
86 | 85 | } |
87 | 86 | return $data; |
88 | 87 | } |
@@ -92,7 +91,7 @@ discard block |
||
92 | 91 | $columns = $module->getDisplayColumns(); |
93 | 92 | $data = ""; |
94 | 93 | foreach ($columns as $column) { |
95 | - $data .= "<td> {{ $" . $model . "->" . $column->getColumn() . " }}</td>" . PHP_EOL; |
|
94 | + $data .= "<td> {{ $".$model."->".$column->getColumn()." }}</td>".PHP_EOL; |
|
96 | 95 | } |
97 | 96 | return $data; |
98 | 97 | } |
@@ -104,7 +103,7 @@ discard block |
||
104 | 103 | $relatedModule = app('laragen')->getModule(Str::plural(strtolower(Str::snake($type->getRelatedModel())))); |
105 | 104 | $displayColumn = $relatedModule->getDisplayColumns()[0]->getColumn(); |
106 | 105 | } |
107 | - $formElement = $this->buildTemplate('backend/views/formelements/' . $page . '/' . $type->getFormType(), [ |
|
106 | + $formElement = $this->buildTemplate('backend/views/formelements/'.$page.'/'.$type->getFormType(), [ |
|
108 | 107 | '{{key}}' => $type->getColumnKey(), |
109 | 108 | '{{column}}' => $type->getColumn(), |
110 | 109 | '{{label}}' => $type->getDisplay(), |
@@ -115,7 +114,7 @@ discard block |
||
115 | 114 | '{{modelNameLowercase}}' => $this->module->getModelNameLowercase(), |
116 | 115 | '{{moduleName}}' => $this->module->getModuleName(), |
117 | 116 | ]); |
118 | - return "@if(auth()->user()->can('view_".$this->module->getModuleName()."_".$type->getColumnKey()."') || auth()->user()->can('edit_".$this->module->getModuleName()."_".$type->getColumnKey()."') )" . PHP_EOL . $formElement . PHP_EOL . "@endif" . PHP_EOL . PHP_EOL; |
|
117 | + return "@if(auth()->user()->can('view_".$this->module->getModuleName()."_".$type->getColumnKey()."') || auth()->user()->can('edit_".$this->module->getModuleName()."_".$type->getColumnKey()."') )".PHP_EOL.$formElement.PHP_EOL."@endif".PHP_EOL.PHP_EOL; |
|
119 | 118 | } |
120 | 119 | |
121 | 120 | |
@@ -124,7 +123,7 @@ discard block |
||
124 | 123 | $displayColumn = $type->getRelatedModule() == 'users' ? 'name' : 'title'; |
125 | 124 | $relatedModule = app('laragen')->getModule($this->module->getModelNameLowercase()."_".$type->getColumn()); |
126 | 125 | $displayColumn = $relatedModule->getDisplayColumns()[0]->getColumn(); |
127 | - $formElement = $this->buildTemplate('backend/views/formelements/' . $page . '/' . $type->getFormType(), [ |
|
126 | + $formElement = $this->buildTemplate('backend/views/formelements/'.$page.'/'.$type->getFormType(), [ |
|
128 | 127 | '{{key}}' => $type->getColumn(), |
129 | 128 | '{{label}}' => $type->getDisplay(), |
130 | 129 | '{{relatedModule}}' => $type->getRelatedModule(), |
@@ -134,7 +133,7 @@ discard block |
||
134 | 133 | '{{relatedModelDisplayColumn}}' => $displayColumn, |
135 | 134 | '{{modelNameLowercase}}' => $this->module->getModelNameLowercase(), |
136 | 135 | '{{modulename}}' => $this->module->getModuleName(), |
137 | - ]) . PHP_EOL; |
|
136 | + ]).PHP_EOL; |
|
138 | 137 | return $formElement; |
139 | 138 | } |
140 | 139 | |
@@ -143,7 +142,7 @@ discard block |
||
143 | 142 | if (!in_array($page, ['create', 'edit'])) return ""; |
144 | 143 | $tabs = $this->module->getTabs(); |
145 | 144 | $tabTitles = $this->module->getTabTitles(); |
146 | - $viewTemplate ='<div class="tab-content px-1 pt-1">'.PHP_EOL; |
|
145 | + $viewTemplate = '<div class="tab-content px-1 pt-1">'.PHP_EOL; |
|
147 | 146 | foreach ($tabs as $key => $tab) { |
148 | 147 | $activeClass = ($key == 0) ? 'active' : ''; |
149 | 148 | $viewTemplate .= $this->getTabs(6).'<div role="tabpanel" class="tab-pane '.$activeClass.'" id="tab'.$key.'" aria-expanded="true" aria-labelledby="base-tab'.$key.'">'.PHP_EOL; |
@@ -152,17 +151,17 @@ discard block |
||
152 | 151 | |
153 | 152 | |
154 | 153 | $typeTemplate = ""; |
155 | - if(is_string($tab)&&!in_array($tab, ['hasFile', 'hasImage', 'Seo'])){ |
|
154 | + if (is_string($tab) && !in_array($tab, ['hasFile', 'hasImage', 'Seo'])) { |
|
156 | 155 | $types = $this->module->getColumnsData(); |
157 | 156 | $type = $types[Str::plural(strtolower(Str::snake($tab)))]; |
158 | 157 | $typeTemplate .= $this->buildMultiple($page, $type); |
159 | - }else{ |
|
158 | + } else { |
|
160 | 159 | foreach ($this->module->getFilteredColumns($tab) as $type) { |
161 | 160 | $typeTemplate .= $this->buildFormElement($page, $type); |
162 | 161 | } |
163 | 162 | } |
164 | 163 | |
165 | - $viewTemplate .= $this->getTabs(9)."@include('backend.".$this->module->getModuleName().".".$page.".form_parts.". strtolower(Str::title($tabTitles[$key])) ."')".PHP_EOL; |
|
164 | + $viewTemplate .= $this->getTabs(9)."@include('backend.".$this->module->getModuleName().".".$page.".form_parts.".strtolower(Str::title($tabTitles[$key]))."')".PHP_EOL; |
|
166 | 165 | |
167 | 166 | $fullFilePath = $this->getPath("resources/views/backend/".$this->module->getModuleName()."/".$page."/form_parts/").strtolower(Str::title($tabTitles[$key])).".blade.php"; |
168 | 167 | file_put_contents($fullFilePath, $typeTemplate); |
@@ -25,8 +25,8 @@ |
||
25 | 25 | protected function getRules() |
26 | 26 | { |
27 | 27 | $validation = []; |
28 | - foreach($this->module->getColumns(true) as $column){ |
|
29 | - $validation[] = "'{$column->getColumnKey()}'" . " => " . $column->getValidationLine(); |
|
28 | + foreach ($this->module->getColumns(true) as $column) { |
|
29 | + $validation[] = "'{$column->getColumnKey()}'"." => ".$column->getValidationLine(); |
|
30 | 30 | } |
31 | 31 | $delimiter = ",\n{$this->getTabs(3)}"; |
32 | 32 | return (implode($delimiter, $validation)); |