@@ -11,136 +11,136 @@ |
||
11 | 11 | |
12 | 12 | class EditViewCompiler extends AbstractViewCompiler |
13 | 13 | { |
14 | - use InputTypeResolverTrait; |
|
15 | - |
|
16 | - /** |
|
17 | - * Compiles the edit view. |
|
18 | - * |
|
19 | - * @param $stub |
|
20 | - * @param $modelName |
|
21 | - * @param $modelData |
|
22 | - * @param $scaffolderConfig |
|
23 | - * @param $hash |
|
24 | - * @param null $extra |
|
25 | - * |
|
26 | - * @return string |
|
27 | - */ |
|
28 | - public function compile($stub, $modelName, $modelData, $scaffolderConfig, $hash, $extra = null) |
|
29 | - { |
|
30 | - if (File::exists(base_path('scaffolder-config/cache/view_edit_' . $hash . self::CACHE_EXT))) |
|
31 | - { |
|
32 | - return $this->store($modelName, $scaffolderConfig, '', new FileToCompile(true, $hash)); |
|
33 | - } |
|
34 | - else |
|
35 | - { |
|
36 | - $this->stub = $stub; |
|
37 | - |
|
38 | - return $this->replaceClassName($modelName) |
|
39 | - ->replaceBreadcrumb($modelName) |
|
40 | - ->addFields($modelData) |
|
41 | - ->replacePrimaryKey($modelData) |
|
42 | - ->replaceRoutePrefix($scaffolderConfig->routing->prefix) |
|
43 | - ->store($modelName, $scaffolderConfig, $this->stub, new FileToCompile(false, $hash)); |
|
44 | - } |
|
45 | - } |
|
46 | - |
|
47 | - /** |
|
48 | - * Store the compiled stub. |
|
49 | - * |
|
50 | - * @param $modelName |
|
51 | - * @param $scaffolderConfig |
|
52 | - * @param $compiled |
|
53 | - * @param FileToCompile $fileToCompile |
|
54 | - * |
|
55 | - * @return string |
|
56 | - */ |
|
57 | - protected function store($modelName, $scaffolderConfig, $compiled, FileToCompile $fileToCompile) |
|
58 | - { |
|
59 | - $folder = PathParser::parse($scaffolderConfig->paths->views) . strtolower($modelName) ; |
|
14 | + use InputTypeResolverTrait; |
|
15 | + |
|
16 | + /** |
|
17 | + * Compiles the edit view. |
|
18 | + * |
|
19 | + * @param $stub |
|
20 | + * @param $modelName |
|
21 | + * @param $modelData |
|
22 | + * @param $scaffolderConfig |
|
23 | + * @param $hash |
|
24 | + * @param null $extra |
|
25 | + * |
|
26 | + * @return string |
|
27 | + */ |
|
28 | + public function compile($stub, $modelName, $modelData, $scaffolderConfig, $hash, $extra = null) |
|
29 | + { |
|
30 | + if (File::exists(base_path('scaffolder-config/cache/view_edit_' . $hash . self::CACHE_EXT))) |
|
31 | + { |
|
32 | + return $this->store($modelName, $scaffolderConfig, '', new FileToCompile(true, $hash)); |
|
33 | + } |
|
34 | + else |
|
35 | + { |
|
36 | + $this->stub = $stub; |
|
37 | + |
|
38 | + return $this->replaceClassName($modelName) |
|
39 | + ->replaceBreadcrumb($modelName) |
|
40 | + ->addFields($modelData) |
|
41 | + ->replacePrimaryKey($modelData) |
|
42 | + ->replaceRoutePrefix($scaffolderConfig->routing->prefix) |
|
43 | + ->store($modelName, $scaffolderConfig, $this->stub, new FileToCompile(false, $hash)); |
|
44 | + } |
|
45 | + } |
|
46 | + |
|
47 | + /** |
|
48 | + * Store the compiled stub. |
|
49 | + * |
|
50 | + * @param $modelName |
|
51 | + * @param $scaffolderConfig |
|
52 | + * @param $compiled |
|
53 | + * @param FileToCompile $fileToCompile |
|
54 | + * |
|
55 | + * @return string |
|
56 | + */ |
|
57 | + protected function store($modelName, $scaffolderConfig, $compiled, FileToCompile $fileToCompile) |
|
58 | + { |
|
59 | + $folder = PathParser::parse($scaffolderConfig->paths->views) . strtolower($modelName) ; |
|
60 | 60 | |
61 | - // create folder directory |
|
62 | - Directory::createIfNotExists($folder, 0755, true); |
|
63 | - |
|
64 | - $path = $folder . '/edit.blade.php'; |
|
65 | - |
|
66 | - // Store in cache |
|
67 | - if ($fileToCompile->cached) |
|
68 | - { |
|
69 | - File::copy(base_path('scaffolder-config/cache/view_edit_' . $fileToCompile->hash . self::CACHE_EXT), $path); |
|
70 | - } |
|
71 | - else |
|
72 | - { |
|
73 | - File::put(base_path('scaffolder-config/cache/view_edit_' . $fileToCompile->hash . self::CACHE_EXT), $compiled); |
|
74 | - File::copy(base_path('scaffolder-config/cache/view_edit_' . $fileToCompile->hash . self::CACHE_EXT), $path); |
|
75 | - } |
|
76 | - |
|
77 | - return $path; |
|
78 | - } |
|
79 | - |
|
80 | - /** |
|
81 | - * Add fields to the edit view. |
|
82 | - * |
|
83 | - * @param $modelData |
|
84 | - * |
|
85 | - * @return $this |
|
86 | - */ |
|
87 | - private function addFields($modelData) |
|
88 | - { |
|
89 | - $fields = ''; |
|
90 | - $firstIteration = true; |
|
91 | - |
|
92 | - foreach ($modelData->fields as $field) |
|
93 | - { |
|
94 | - if ($firstIteration) |
|
95 | - { |
|
96 | - $fields .= sprintf(self::getInputFor($field) . PHP_EOL, $field->name); |
|
97 | - $firstIteration = false; |
|
98 | - } |
|
99 | - else |
|
100 | - { |
|
101 | - $fields .= sprintf("\t" . self::getInputFor($field) . PHP_EOL, $field->name); |
|
102 | - } |
|
103 | - } |
|
104 | - |
|
105 | - $this->stub = str_replace('{{fields}}', $fields, $this->stub); |
|
106 | - |
|
107 | - return $this; |
|
108 | - } |
|
109 | - |
|
110 | - /** |
|
111 | - * Replace the prefix. |
|
112 | - * |
|
113 | - * @param $prefix |
|
114 | - * |
|
115 | - * @return $this |
|
116 | - */ |
|
117 | - private function replaceRoutePrefix($prefix) |
|
118 | - { |
|
119 | - $this->stub = str_replace('{{route_prefix}}', $prefix, $this->stub); |
|
120 | - |
|
121 | - return $this; |
|
122 | - } |
|
123 | - |
|
124 | - /** |
|
125 | - * Replace the primary key. |
|
126 | - * |
|
127 | - * @param $modelData |
|
128 | - */ |
|
129 | - private function replacePrimaryKey($modelData) |
|
130 | - { |
|
131 | - $primaryKey = 'id'; |
|
132 | - |
|
133 | - foreach ($modelData->fields as $field) |
|
134 | - { |
|
135 | - if ($field->index == 'primary') |
|
136 | - { |
|
137 | - $primaryKey = $field->name; |
|
138 | - break; |
|
139 | - } |
|
140 | - } |
|
141 | - |
|
142 | - $this->stub = str_replace('{{primaryKey}}', $primaryKey, $this->stub); |
|
143 | - |
|
144 | - return $this; |
|
145 | - } |
|
61 | + // create folder directory |
|
62 | + Directory::createIfNotExists($folder, 0755, true); |
|
63 | + |
|
64 | + $path = $folder . '/edit.blade.php'; |
|
65 | + |
|
66 | + // Store in cache |
|
67 | + if ($fileToCompile->cached) |
|
68 | + { |
|
69 | + File::copy(base_path('scaffolder-config/cache/view_edit_' . $fileToCompile->hash . self::CACHE_EXT), $path); |
|
70 | + } |
|
71 | + else |
|
72 | + { |
|
73 | + File::put(base_path('scaffolder-config/cache/view_edit_' . $fileToCompile->hash . self::CACHE_EXT), $compiled); |
|
74 | + File::copy(base_path('scaffolder-config/cache/view_edit_' . $fileToCompile->hash . self::CACHE_EXT), $path); |
|
75 | + } |
|
76 | + |
|
77 | + return $path; |
|
78 | + } |
|
79 | + |
|
80 | + /** |
|
81 | + * Add fields to the edit view. |
|
82 | + * |
|
83 | + * @param $modelData |
|
84 | + * |
|
85 | + * @return $this |
|
86 | + */ |
|
87 | + private function addFields($modelData) |
|
88 | + { |
|
89 | + $fields = ''; |
|
90 | + $firstIteration = true; |
|
91 | + |
|
92 | + foreach ($modelData->fields as $field) |
|
93 | + { |
|
94 | + if ($firstIteration) |
|
95 | + { |
|
96 | + $fields .= sprintf(self::getInputFor($field) . PHP_EOL, $field->name); |
|
97 | + $firstIteration = false; |
|
98 | + } |
|
99 | + else |
|
100 | + { |
|
101 | + $fields .= sprintf("\t" . self::getInputFor($field) . PHP_EOL, $field->name); |
|
102 | + } |
|
103 | + } |
|
104 | + |
|
105 | + $this->stub = str_replace('{{fields}}', $fields, $this->stub); |
|
106 | + |
|
107 | + return $this; |
|
108 | + } |
|
109 | + |
|
110 | + /** |
|
111 | + * Replace the prefix. |
|
112 | + * |
|
113 | + * @param $prefix |
|
114 | + * |
|
115 | + * @return $this |
|
116 | + */ |
|
117 | + private function replaceRoutePrefix($prefix) |
|
118 | + { |
|
119 | + $this->stub = str_replace('{{route_prefix}}', $prefix, $this->stub); |
|
120 | + |
|
121 | + return $this; |
|
122 | + } |
|
123 | + |
|
124 | + /** |
|
125 | + * Replace the primary key. |
|
126 | + * |
|
127 | + * @param $modelData |
|
128 | + */ |
|
129 | + private function replacePrimaryKey($modelData) |
|
130 | + { |
|
131 | + $primaryKey = 'id'; |
|
132 | + |
|
133 | + foreach ($modelData->fields as $field) |
|
134 | + { |
|
135 | + if ($field->index == 'primary') |
|
136 | + { |
|
137 | + $primaryKey = $field->name; |
|
138 | + break; |
|
139 | + } |
|
140 | + } |
|
141 | + |
|
142 | + $this->stub = str_replace('{{primaryKey}}', $primaryKey, $this->stub); |
|
143 | + |
|
144 | + return $this; |
|
145 | + } |
|
146 | 146 | } |
147 | 147 | \ No newline at end of file |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | */ |
28 | 28 | public function compile($stub, $modelName, $modelData, $scaffolderConfig, $hash, $extra = null) |
29 | 29 | { |
30 | - if (File::exists(base_path('scaffolder-config/cache/view_edit_' . $hash . self::CACHE_EXT))) |
|
30 | + if (File::exists(base_path('scaffolder-config/cache/view_edit_'.$hash.self::CACHE_EXT))) |
|
31 | 31 | { |
32 | 32 | return $this->store($modelName, $scaffolderConfig, '', new FileToCompile(true, $hash)); |
33 | 33 | } |
@@ -56,22 +56,22 @@ discard block |
||
56 | 56 | */ |
57 | 57 | protected function store($modelName, $scaffolderConfig, $compiled, FileToCompile $fileToCompile) |
58 | 58 | { |
59 | - $folder = PathParser::parse($scaffolderConfig->paths->views) . strtolower($modelName) ; |
|
59 | + $folder = PathParser::parse($scaffolderConfig->paths->views).strtolower($modelName); |
|
60 | 60 | |
61 | 61 | // create folder directory |
62 | 62 | Directory::createIfNotExists($folder, 0755, true); |
63 | 63 | |
64 | - $path = $folder . '/edit.blade.php'; |
|
64 | + $path = $folder.'/edit.blade.php'; |
|
65 | 65 | |
66 | 66 | // Store in cache |
67 | 67 | if ($fileToCompile->cached) |
68 | 68 | { |
69 | - File::copy(base_path('scaffolder-config/cache/view_edit_' . $fileToCompile->hash . self::CACHE_EXT), $path); |
|
69 | + File::copy(base_path('scaffolder-config/cache/view_edit_'.$fileToCompile->hash.self::CACHE_EXT), $path); |
|
70 | 70 | } |
71 | 71 | else |
72 | 72 | { |
73 | - File::put(base_path('scaffolder-config/cache/view_edit_' . $fileToCompile->hash . self::CACHE_EXT), $compiled); |
|
74 | - File::copy(base_path('scaffolder-config/cache/view_edit_' . $fileToCompile->hash . self::CACHE_EXT), $path); |
|
73 | + File::put(base_path('scaffolder-config/cache/view_edit_'.$fileToCompile->hash.self::CACHE_EXT), $compiled); |
|
74 | + File::copy(base_path('scaffolder-config/cache/view_edit_'.$fileToCompile->hash.self::CACHE_EXT), $path); |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | return $path; |
@@ -93,12 +93,12 @@ discard block |
||
93 | 93 | { |
94 | 94 | if ($firstIteration) |
95 | 95 | { |
96 | - $fields .= sprintf(self::getInputFor($field) . PHP_EOL, $field->name); |
|
96 | + $fields .= sprintf(self::getInputFor($field).PHP_EOL, $field->name); |
|
97 | 97 | $firstIteration = false; |
98 | 98 | } |
99 | 99 | else |
100 | 100 | { |
101 | - $fields .= sprintf("\t" . self::getInputFor($field) . PHP_EOL, $field->name); |
|
101 | + $fields .= sprintf("\t".self::getInputFor($field).PHP_EOL, $field->name); |
|
102 | 102 | } |
103 | 103 | } |
104 | 104 |
@@ -30,8 +30,7 @@ discard block |
||
30 | 30 | if (File::exists(base_path('scaffolder-config/cache/view_edit_' . $hash . self::CACHE_EXT))) |
31 | 31 | { |
32 | 32 | return $this->store($modelName, $scaffolderConfig, '', new FileToCompile(true, $hash)); |
33 | - } |
|
34 | - else |
|
33 | + } else |
|
35 | 34 | { |
36 | 35 | $this->stub = $stub; |
37 | 36 | |
@@ -67,8 +66,7 @@ discard block |
||
67 | 66 | if ($fileToCompile->cached) |
68 | 67 | { |
69 | 68 | File::copy(base_path('scaffolder-config/cache/view_edit_' . $fileToCompile->hash . self::CACHE_EXT), $path); |
70 | - } |
|
71 | - else |
|
69 | + } else |
|
72 | 70 | { |
73 | 71 | File::put(base_path('scaffolder-config/cache/view_edit_' . $fileToCompile->hash . self::CACHE_EXT), $compiled); |
74 | 72 | File::copy(base_path('scaffolder-config/cache/view_edit_' . $fileToCompile->hash . self::CACHE_EXT), $path); |
@@ -95,8 +93,7 @@ discard block |
||
95 | 93 | { |
96 | 94 | $fields .= sprintf(self::getInputFor($field) . PHP_EOL, $field->name); |
97 | 95 | $firstIteration = false; |
98 | - } |
|
99 | - else |
|
96 | + } else |
|
100 | 97 | { |
101 | 98 | $fields .= sprintf("\t" . self::getInputFor($field) . PHP_EOL, $field->name); |
102 | 99 | } |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | */ |
25 | 25 | public function compile($stub, $modelName, $modelData, $scaffolderConfig, $hash, $extra = null) |
26 | 26 | { |
27 | - if (File::exists(base_path('scaffolder-config/cache/view_index_' . $hash . self::CACHE_EXT))) |
|
27 | + if (File::exists(base_path('scaffolder-config/cache/view_index_'.$hash.self::CACHE_EXT))) |
|
28 | 28 | { |
29 | 29 | return $this->store($modelName, $scaffolderConfig, '', new FileToCompile(true, $hash)); |
30 | 30 | } |
@@ -53,22 +53,22 @@ discard block |
||
53 | 53 | */ |
54 | 54 | protected function store($modelName, $scaffolderConfig, $compiled, FileToCompile $fileToCompile) |
55 | 55 | { |
56 | - $folder = PathParser::parse($scaffolderConfig->paths->views) . strtolower($modelName) ; |
|
56 | + $folder = PathParser::parse($scaffolderConfig->paths->views).strtolower($modelName); |
|
57 | 57 | |
58 | 58 | // create folder directory |
59 | 59 | Directory::createIfNotExists($folder, 0755, true); |
60 | 60 | |
61 | - $path = $folder . '/index.blade.php'; |
|
61 | + $path = $folder.'/index.blade.php'; |
|
62 | 62 | |
63 | 63 | // Store in cache |
64 | 64 | if ($fileToCompile->cached) |
65 | 65 | { |
66 | - File::copy(base_path('scaffolder-config/cache/view_index_' . $fileToCompile->hash . self::CACHE_EXT), $path); |
|
66 | + File::copy(base_path('scaffolder-config/cache/view_index_'.$fileToCompile->hash.self::CACHE_EXT), $path); |
|
67 | 67 | } |
68 | 68 | else |
69 | 69 | { |
70 | - File::put(base_path('scaffolder-config/cache/view_index_' . $fileToCompile->hash . self::CACHE_EXT), $compiled); |
|
71 | - File::copy(base_path('scaffolder-config/cache/view_index_' . $fileToCompile->hash . self::CACHE_EXT), $path); |
|
70 | + File::put(base_path('scaffolder-config/cache/view_index_'.$fileToCompile->hash.self::CACHE_EXT), $compiled); |
|
71 | + File::copy(base_path('scaffolder-config/cache/view_index_'.$fileToCompile->hash.self::CACHE_EXT), $path); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | return $path; |
@@ -93,12 +93,12 @@ discard block |
||
93 | 93 | { |
94 | 94 | if ($firstIteration) |
95 | 95 | { |
96 | - $fields .= sprintf("{ data: '%s', name: '%s' }," . PHP_EOL, $field->name, $field->name); |
|
96 | + $fields .= sprintf("{ data: '%s', name: '%s' },".PHP_EOL, $field->name, $field->name); |
|
97 | 97 | $firstIteration = false; |
98 | 98 | } |
99 | 99 | else |
100 | 100 | { |
101 | - $fields .= sprintf("\t\t\t\t{ data: '%s', name: '%s' }," . PHP_EOL, $field->name, $field->name); |
|
101 | + $fields .= sprintf("\t\t\t\t{ data: '%s', name: '%s' },".PHP_EOL, $field->name, $field->name); |
|
102 | 102 | } |
103 | 103 | } |
104 | 104 | } |
@@ -127,13 +127,13 @@ discard block |
||
127 | 127 | { |
128 | 128 | if ($firstIteration) |
129 | 129 | { |
130 | - $fields .= sprintf("<th>%s</th>" . PHP_EOL, ucfirst($field->name)); |
|
130 | + $fields .= sprintf("<th>%s</th>".PHP_EOL, ucfirst($field->name)); |
|
131 | 131 | $firstIteration = false; |
132 | 132 | |
133 | 133 | } |
134 | 134 | else |
135 | 135 | { |
136 | - $fields .= sprintf("\t\t\t<th>%s</th>" . PHP_EOL, ucfirst($field->name)); |
|
136 | + $fields .= sprintf("\t\t\t<th>%s</th>".PHP_EOL, ucfirst($field->name)); |
|
137 | 137 | } |
138 | 138 | } |
139 | 139 | } |
@@ -9,266 +9,266 @@ |
||
9 | 9 | |
10 | 10 | abstract class AbstractCompiler |
11 | 11 | { |
12 | - protected $cachePrefix ; |
|
13 | - protected $stubFilename; |
|
14 | - |
|
15 | - protected $stub; |
|
16 | - protected $scaffolderConfig ; |
|
17 | - protected $modelName ; |
|
18 | - protected $modelData ; |
|
19 | - protected $stubsDirectory ; |
|
20 | - |
|
21 | - protected $eagerTable ; |
|
22 | - |
|
23 | - const CACHE_EXT = '.scf'; |
|
24 | - |
|
25 | - public function __construct($scaffolderConfig, $modelData = null) |
|
26 | - { |
|
27 | - $this->modelName = isset($modelData->modelName) ? $modelData->modelName : null ; |
|
28 | - $this->modelData = $modelData ; |
|
29 | - $this->scaffolderConfig = $scaffolderConfig ; |
|
30 | - |
|
31 | - $this->stub = File::get($this->stubsDirectory . $this->stubFilename ); |
|
32 | - } |
|
33 | - |
|
34 | - /** |
|
35 | - * Compiles . |
|
36 | - * |
|
37 | - * @param null $extra |
|
38 | - * |
|
39 | - * @return string |
|
40 | - */ |
|
41 | - public function compile($extra = null) |
|
42 | - { |
|
43 | - if (File::exists(base_path('scaffolder-config/cache/' . $this->cachePrefix . $this->modelData->modelHash . self::CACHE_EXT))) |
|
44 | - { |
|
45 | - return $this->store(new FileToCompile(true, $this->modelData->modelHash)); |
|
46 | - } |
|
47 | - else |
|
48 | - { |
|
49 | - |
|
50 | - return $this->replacePrimaryKey() |
|
51 | - ->replaceClassName() |
|
52 | - ->replaceTableName() |
|
53 | - ->replaceRoutePrefix() |
|
54 | - ->replaceAndStore(); |
|
55 | - } |
|
56 | - } |
|
57 | - |
|
58 | - /** |
|
59 | - * Replace and store the Stub. |
|
60 | - * |
|
61 | - * @return string |
|
62 | - */ |
|
63 | - abstract protected function replaceAndStore(); |
|
64 | - |
|
65 | - /** |
|
66 | - * Store the compiled stub. |
|
67 | - * |
|
68 | - * @param string $eagerTable |
|
69 | - * |
|
70 | - * @return string |
|
71 | - */ |
|
72 | - protected function setEagerTable($eagerTable){ |
|
73 | - $this->eagerTable = $eagerTable.'.'; |
|
74 | - } |
|
75 | - |
|
76 | - /** |
|
77 | - * Store the compiled stub. |
|
78 | - * |
|
79 | - * @param FileToCompile $fileToCompile |
|
80 | - * |
|
81 | - * @return string |
|
82 | - */ |
|
83 | - protected function store(FileToCompile $fileToCompile) |
|
84 | - { |
|
85 | - $path = $this->getOutputFilename(); |
|
86 | - |
|
87 | - // Store in cache |
|
88 | - if ($fileToCompile->cached) |
|
89 | - { |
|
90 | - File::copy(base_path('scaffolder-config/cache/' . $this->cachePrefix . $fileToCompile->hash . self::CACHE_EXT), $path); |
|
91 | - } |
|
92 | - else |
|
93 | - { |
|
94 | - File::put(base_path('scaffolder-config/cache/' . $this->cachePrefix . $fileToCompile->hash . self::CACHE_EXT), $this->stub); |
|
95 | - File::copy(base_path('scaffolder-config/cache/' . $this->cachePrefix . $fileToCompile->hash . self::CACHE_EXT), $path); |
|
96 | - } |
|
97 | - |
|
98 | - return $path; |
|
99 | - } |
|
100 | - |
|
101 | - /** |
|
102 | - * Get output filename |
|
103 | - * |
|
104 | - * |
|
105 | - * @return $this |
|
106 | - */ |
|
107 | - abstract protected function getOutputFilename(); |
|
108 | - |
|
109 | - /** |
|
110 | - * Replace the primary key. |
|
111 | - * |
|
112 | - * @param $this->modelData |
|
113 | - */ |
|
114 | - protected function replacePrimaryKey() |
|
115 | - { |
|
12 | + protected $cachePrefix ; |
|
13 | + protected $stubFilename; |
|
14 | + |
|
15 | + protected $stub; |
|
16 | + protected $scaffolderConfig ; |
|
17 | + protected $modelName ; |
|
18 | + protected $modelData ; |
|
19 | + protected $stubsDirectory ; |
|
20 | + |
|
21 | + protected $eagerTable ; |
|
22 | + |
|
23 | + const CACHE_EXT = '.scf'; |
|
24 | + |
|
25 | + public function __construct($scaffolderConfig, $modelData = null) |
|
26 | + { |
|
27 | + $this->modelName = isset($modelData->modelName) ? $modelData->modelName : null ; |
|
28 | + $this->modelData = $modelData ; |
|
29 | + $this->scaffolderConfig = $scaffolderConfig ; |
|
30 | + |
|
31 | + $this->stub = File::get($this->stubsDirectory . $this->stubFilename ); |
|
32 | + } |
|
33 | + |
|
34 | + /** |
|
35 | + * Compiles . |
|
36 | + * |
|
37 | + * @param null $extra |
|
38 | + * |
|
39 | + * @return string |
|
40 | + */ |
|
41 | + public function compile($extra = null) |
|
42 | + { |
|
43 | + if (File::exists(base_path('scaffolder-config/cache/' . $this->cachePrefix . $this->modelData->modelHash . self::CACHE_EXT))) |
|
44 | + { |
|
45 | + return $this->store(new FileToCompile(true, $this->modelData->modelHash)); |
|
46 | + } |
|
47 | + else |
|
48 | + { |
|
49 | + |
|
50 | + return $this->replacePrimaryKey() |
|
51 | + ->replaceClassName() |
|
52 | + ->replaceTableName() |
|
53 | + ->replaceRoutePrefix() |
|
54 | + ->replaceAndStore(); |
|
55 | + } |
|
56 | + } |
|
57 | + |
|
58 | + /** |
|
59 | + * Replace and store the Stub. |
|
60 | + * |
|
61 | + * @return string |
|
62 | + */ |
|
63 | + abstract protected function replaceAndStore(); |
|
64 | + |
|
65 | + /** |
|
66 | + * Store the compiled stub. |
|
67 | + * |
|
68 | + * @param string $eagerTable |
|
69 | + * |
|
70 | + * @return string |
|
71 | + */ |
|
72 | + protected function setEagerTable($eagerTable){ |
|
73 | + $this->eagerTable = $eagerTable.'.'; |
|
74 | + } |
|
75 | + |
|
76 | + /** |
|
77 | + * Store the compiled stub. |
|
78 | + * |
|
79 | + * @param FileToCompile $fileToCompile |
|
80 | + * |
|
81 | + * @return string |
|
82 | + */ |
|
83 | + protected function store(FileToCompile $fileToCompile) |
|
84 | + { |
|
85 | + $path = $this->getOutputFilename(); |
|
86 | + |
|
87 | + // Store in cache |
|
88 | + if ($fileToCompile->cached) |
|
89 | + { |
|
90 | + File::copy(base_path('scaffolder-config/cache/' . $this->cachePrefix . $fileToCompile->hash . self::CACHE_EXT), $path); |
|
91 | + } |
|
92 | + else |
|
93 | + { |
|
94 | + File::put(base_path('scaffolder-config/cache/' . $this->cachePrefix . $fileToCompile->hash . self::CACHE_EXT), $this->stub); |
|
95 | + File::copy(base_path('scaffolder-config/cache/' . $this->cachePrefix . $fileToCompile->hash . self::CACHE_EXT), $path); |
|
96 | + } |
|
97 | + |
|
98 | + return $path; |
|
99 | + } |
|
100 | + |
|
101 | + /** |
|
102 | + * Get output filename |
|
103 | + * |
|
104 | + * |
|
105 | + * @return $this |
|
106 | + */ |
|
107 | + abstract protected function getOutputFilename(); |
|
108 | + |
|
109 | + /** |
|
110 | + * Replace the primary key. |
|
111 | + * |
|
112 | + * @param $this->modelData |
|
113 | + */ |
|
114 | + protected function replacePrimaryKey() |
|
115 | + { |
|
116 | 116 | |
117 | - $primaryKey = $this->getPrimaryKeyField()->name; |
|
118 | - |
|
119 | - $this->stub = str_replace('{{primary_key}}', $primaryKey, $this->stub); |
|
120 | - |
|
121 | - return $this; |
|
122 | - } |
|
123 | - |
|
124 | - protected function getPrimaryKeyField(){ |
|
125 | - $primaryKey = new stdClass; |
|
126 | - $primaryKey->name = "id" ; |
|
127 | - $primaryKey->index = "primary" ; |
|
128 | - $primaryKey->declared = false ; |
|
129 | - $primaryKey->type = new stdClass ; |
|
130 | - $primaryKey->type->ui = 'label' ; |
|
131 | - $primaryKey->type->db = 'integer' ; |
|
132 | - $primaryKey->foreignKey = []; |
|
133 | - $primaryKey->validations = "required" ; |
|
134 | - |
|
135 | - foreach ($this->modelData->fields as $field) |
|
136 | - { |
|
137 | - if ($field->index == 'primary') |
|
138 | - { |
|
139 | - $primaryKey = $field ; |
|
140 | - break; |
|
141 | - } |
|
142 | - } |
|
143 | - |
|
144 | - return $primaryKey ; |
|
145 | - } |
|
146 | - |
|
147 | - /** |
|
148 | - * Replace the class name. |
|
149 | - * |
|
150 | - * |
|
151 | - * @return $this |
|
152 | - */ |
|
153 | - protected function replaceClassName() |
|
154 | - { |
|
155 | - $this->stub = str_replace('{{class_name}}', $this->modelName, $this->stub); |
|
156 | - $this->stub = str_replace('{{class_name_lw}}', strtolower($this->modelName), $this->stub); |
|
157 | - |
|
158 | - return $this; |
|
159 | - } |
|
160 | - |
|
161 | - /** |
|
162 | - * Replace the table name. |
|
163 | - * |
|
164 | - * @return $this |
|
165 | - */ |
|
166 | - protected function replaceTableName() |
|
167 | - { |
|
168 | - $this->stub = str_replace('{{table_name}}', $this->modelData->tableName, $this->stub); |
|
169 | - |
|
170 | - return $this; |
|
171 | - } |
|
172 | - |
|
173 | - /** |
|
174 | - * Replace the namespace. |
|
175 | - * |
|
176 | - * @return $this |
|
177 | - */ |
|
178 | - protected function replaceNamespace() |
|
179 | - { |
|
180 | - $this->stub = str_replace('{{namespace}}', $this->scaffolderConfig->generator->namespaces->models, $this->stub); |
|
181 | - |
|
182 | - return $this; |
|
183 | - } |
|
184 | - |
|
185 | - /** |
|
186 | - * Replace the foreign strings by field. |
|
187 | - * |
|
188 | - * @param stdClass $field |
|
189 | - * @param string $originalStubPart |
|
190 | - * |
|
191 | - * @return $this |
|
192 | - */ |
|
193 | - protected function replaceForeingStrings($field, $originalStubPart){ |
|
194 | - $replaceStub = str_replace('{{foreign_table}}', $field->foreignKey->table, $originalStubPart); |
|
195 | - $replaceStub = str_replace('{{table_name}}', $this->modelData->tableName, $replaceStub); |
|
196 | - $replaceStub = str_replace('{{foreign_field}}', $field->foreignKey->field, $replaceStub); |
|
197 | - $replaceStub = str_replace('{{foreign_model}}', ucwords($field->foreignKey->table), $replaceStub); |
|
198 | - $replaceStub = str_replace('{{field}}', $field->name, $replaceStub); |
|
199 | - |
|
200 | - if(isset($this->scaffolderConfig->generator->namespaces)) |
|
201 | - $replaceStub = str_replace('{{model_namespace}}', $this->scaffolderConfig->generator->namespaces->models, $replaceStub); |
|
202 | - |
|
203 | - return $replaceStub; |
|
117 | + $primaryKey = $this->getPrimaryKeyField()->name; |
|
118 | + |
|
119 | + $this->stub = str_replace('{{primary_key}}', $primaryKey, $this->stub); |
|
120 | + |
|
121 | + return $this; |
|
122 | + } |
|
123 | + |
|
124 | + protected function getPrimaryKeyField(){ |
|
125 | + $primaryKey = new stdClass; |
|
126 | + $primaryKey->name = "id" ; |
|
127 | + $primaryKey->index = "primary" ; |
|
128 | + $primaryKey->declared = false ; |
|
129 | + $primaryKey->type = new stdClass ; |
|
130 | + $primaryKey->type->ui = 'label' ; |
|
131 | + $primaryKey->type->db = 'integer' ; |
|
132 | + $primaryKey->foreignKey = []; |
|
133 | + $primaryKey->validations = "required" ; |
|
134 | + |
|
135 | + foreach ($this->modelData->fields as $field) |
|
136 | + { |
|
137 | + if ($field->index == 'primary') |
|
138 | + { |
|
139 | + $primaryKey = $field ; |
|
140 | + break; |
|
141 | + } |
|
142 | + } |
|
143 | + |
|
144 | + return $primaryKey ; |
|
145 | + } |
|
146 | + |
|
147 | + /** |
|
148 | + * Replace the class name. |
|
149 | + * |
|
150 | + * |
|
151 | + * @return $this |
|
152 | + */ |
|
153 | + protected function replaceClassName() |
|
154 | + { |
|
155 | + $this->stub = str_replace('{{class_name}}', $this->modelName, $this->stub); |
|
156 | + $this->stub = str_replace('{{class_name_lw}}', strtolower($this->modelName), $this->stub); |
|
157 | + |
|
158 | + return $this; |
|
159 | + } |
|
160 | + |
|
161 | + /** |
|
162 | + * Replace the table name. |
|
163 | + * |
|
164 | + * @return $this |
|
165 | + */ |
|
166 | + protected function replaceTableName() |
|
167 | + { |
|
168 | + $this->stub = str_replace('{{table_name}}', $this->modelData->tableName, $this->stub); |
|
169 | + |
|
170 | + return $this; |
|
171 | + } |
|
172 | + |
|
173 | + /** |
|
174 | + * Replace the namespace. |
|
175 | + * |
|
176 | + * @return $this |
|
177 | + */ |
|
178 | + protected function replaceNamespace() |
|
179 | + { |
|
180 | + $this->stub = str_replace('{{namespace}}', $this->scaffolderConfig->generator->namespaces->models, $this->stub); |
|
181 | + |
|
182 | + return $this; |
|
183 | + } |
|
184 | + |
|
185 | + /** |
|
186 | + * Replace the foreign strings by field. |
|
187 | + * |
|
188 | + * @param stdClass $field |
|
189 | + * @param string $originalStubPart |
|
190 | + * |
|
191 | + * @return $this |
|
192 | + */ |
|
193 | + protected function replaceForeingStrings($field, $originalStubPart){ |
|
194 | + $replaceStub = str_replace('{{foreign_table}}', $field->foreignKey->table, $originalStubPart); |
|
195 | + $replaceStub = str_replace('{{table_name}}', $this->modelData->tableName, $replaceStub); |
|
196 | + $replaceStub = str_replace('{{foreign_field}}', $field->foreignKey->field, $replaceStub); |
|
197 | + $replaceStub = str_replace('{{foreign_model}}', ucwords($field->foreignKey->table), $replaceStub); |
|
198 | + $replaceStub = str_replace('{{field}}', $field->name, $replaceStub); |
|
199 | + |
|
200 | + if(isset($this->scaffolderConfig->generator->namespaces)) |
|
201 | + $replaceStub = str_replace('{{model_namespace}}', $this->scaffolderConfig->generator->namespaces->models, $replaceStub); |
|
202 | + |
|
203 | + return $replaceStub; |
|
204 | 204 | |
205 | - } |
|
206 | - |
|
207 | - /** |
|
208 | - * Replace the fields strings by field. |
|
209 | - * |
|
210 | - * @param stdClass $field |
|
211 | - * @param string $originalStubPart |
|
212 | - * |
|
213 | - * @return $this |
|
214 | - */ |
|
215 | - protected function replaceFieldStrings($field, $originalStubPart){ |
|
216 | - $replaceStub = str_replace('{{field}}', $field->name, $originalStubPart); |
|
205 | + } |
|
206 | + |
|
207 | + /** |
|
208 | + * Replace the fields strings by field. |
|
209 | + * |
|
210 | + * @param stdClass $field |
|
211 | + * @param string $originalStubPart |
|
212 | + * |
|
213 | + * @return $this |
|
214 | + */ |
|
215 | + protected function replaceFieldStrings($field, $originalStubPart){ |
|
216 | + $replaceStub = str_replace('{{field}}', $field->name, $originalStubPart); |
|
217 | 217 | |
218 | - if($this->eagerTable) $this->eagerTable.'.' ; |
|
218 | + if($this->eagerTable) $this->eagerTable.'.' ; |
|
219 | 219 | |
220 | - $replaceStub = str_replace('{{eager_table}}', $this->eagerTable, $replaceStub); |
|
220 | + $replaceStub = str_replace('{{eager_table}}', $this->eagerTable, $replaceStub); |
|
221 | 221 | |
222 | - return $replaceStub; |
|
222 | + return $replaceStub; |
|
223 | 223 | |
224 | - } |
|
225 | - |
|
226 | - /** |
|
227 | - * Replace the prefix. |
|
228 | - * |
|
229 | - * @return $this |
|
230 | - */ |
|
231 | - protected function replaceRoutePrefix() |
|
232 | - { |
|
233 | - $this->stub = str_replace('{{route_prefix}}', $this->scaffolderConfig->generator->routing->prefix, $this->stub); |
|
234 | - |
|
235 | - return $this; |
|
236 | - } |
|
237 | - |
|
238 | - /** |
|
239 | - * get anoter model data |
|
240 | - * |
|
241 | - * @param string $tableName |
|
242 | - * |
|
243 | - * @return $this |
|
244 | - */ |
|
245 | - protected $modelDataArray = []; |
|
246 | - protected function getModelData($tableName){ |
|
224 | + } |
|
225 | + |
|
226 | + /** |
|
227 | + * Replace the prefix. |
|
228 | + * |
|
229 | + * @return $this |
|
230 | + */ |
|
231 | + protected function replaceRoutePrefix() |
|
232 | + { |
|
233 | + $this->stub = str_replace('{{route_prefix}}', $this->scaffolderConfig->generator->routing->prefix, $this->stub); |
|
234 | + |
|
235 | + return $this; |
|
236 | + } |
|
237 | + |
|
238 | + /** |
|
239 | + * get anoter model data |
|
240 | + * |
|
241 | + * @param string $tableName |
|
242 | + * |
|
243 | + * @return $this |
|
244 | + */ |
|
245 | + protected $modelDataArray = []; |
|
246 | + protected function getModelData($tableName){ |
|
247 | 247 | |
248 | - if(array_key_exists($tableName, $this->modelDataArray)){ |
|
249 | - return $this->modelDataArray[$tableName]; |
|
250 | - } |
|
251 | - else { |
|
248 | + if(array_key_exists($tableName, $this->modelDataArray)){ |
|
249 | + return $this->modelDataArray[$tableName]; |
|
250 | + } |
|
251 | + else { |
|
252 | 252 | |
253 | - $modelFilename = base_path('scaffolder-config/models/') . $tableName . '.json' ; |
|
253 | + $modelFilename = base_path('scaffolder-config/models/') . $tableName . '.json' ; |
|
254 | 254 | |
255 | - $modelData = Json::decodeFile($modelFilename); |
|
255 | + $modelData = Json::decodeFile($modelFilename); |
|
256 | 256 | |
257 | - // Get model name |
|
258 | - $modelName = ucwords($tableName); |
|
257 | + // Get model name |
|
258 | + $modelName = ucwords($tableName); |
|
259 | 259 | |
260 | - // Get model hash |
|
261 | - $modelHash = md5_file($modelFilename); |
|
260 | + // Get model hash |
|
261 | + $modelHash = md5_file($modelFilename); |
|
262 | 262 | |
263 | - // Set model name |
|
264 | - $modelData->modelName = $modelName ; |
|
263 | + // Set model name |
|
264 | + $modelData->modelName = $modelName ; |
|
265 | 265 | |
266 | - // Set model name |
|
267 | - $modelData->modelHash = $modelHash ; |
|
266 | + // Set model name |
|
267 | + $modelData->modelHash = $modelHash ; |
|
268 | 268 | |
269 | - $this->modelDataArray[$tableName] = $modelData; |
|
269 | + $this->modelDataArray[$tableName] = $modelData; |
|
270 | 270 | |
271 | - return $this->modelDataArray[$tableName]; |
|
272 | - } |
|
273 | - } |
|
271 | + return $this->modelDataArray[$tableName]; |
|
272 | + } |
|
273 | + } |
|
274 | 274 | } |
275 | 275 | \ No newline at end of file |
@@ -5,30 +5,30 @@ discard block |
||
5 | 5 | use Scaffolder\Compilers\Support\FileToCompile; |
6 | 6 | use Illuminate\Support\Facades\File; |
7 | 7 | use Scaffolder\Support\Json; |
8 | -use stdClass ; |
|
8 | +use stdClass; |
|
9 | 9 | |
10 | 10 | abstract class AbstractCompiler |
11 | 11 | { |
12 | - protected $cachePrefix ; |
|
12 | + protected $cachePrefix; |
|
13 | 13 | protected $stubFilename; |
14 | 14 | |
15 | 15 | protected $stub; |
16 | - protected $scaffolderConfig ; |
|
17 | - protected $modelName ; |
|
18 | - protected $modelData ; |
|
19 | - protected $stubsDirectory ; |
|
16 | + protected $scaffolderConfig; |
|
17 | + protected $modelName; |
|
18 | + protected $modelData; |
|
19 | + protected $stubsDirectory; |
|
20 | 20 | |
21 | - protected $eagerTable ; |
|
21 | + protected $eagerTable; |
|
22 | 22 | |
23 | 23 | const CACHE_EXT = '.scf'; |
24 | 24 | |
25 | 25 | public function __construct($scaffolderConfig, $modelData = null) |
26 | 26 | { |
27 | - $this->modelName = isset($modelData->modelName) ? $modelData->modelName : null ; |
|
28 | - $this->modelData = $modelData ; |
|
29 | - $this->scaffolderConfig = $scaffolderConfig ; |
|
27 | + $this->modelName = isset($modelData->modelName) ? $modelData->modelName : null; |
|
28 | + $this->modelData = $modelData; |
|
29 | + $this->scaffolderConfig = $scaffolderConfig; |
|
30 | 30 | |
31 | - $this->stub = File::get($this->stubsDirectory . $this->stubFilename ); |
|
31 | + $this->stub = File::get($this->stubsDirectory.$this->stubFilename); |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | /** |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | */ |
41 | 41 | public function compile($extra = null) |
42 | 42 | { |
43 | - if (File::exists(base_path('scaffolder-config/cache/' . $this->cachePrefix . $this->modelData->modelHash . self::CACHE_EXT))) |
|
43 | + if (File::exists(base_path('scaffolder-config/cache/'.$this->cachePrefix.$this->modelData->modelHash.self::CACHE_EXT))) |
|
44 | 44 | { |
45 | 45 | return $this->store(new FileToCompile(true, $this->modelData->modelHash)); |
46 | 46 | } |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | * |
70 | 70 | * @return string |
71 | 71 | */ |
72 | - protected function setEagerTable($eagerTable){ |
|
72 | + protected function setEagerTable($eagerTable) { |
|
73 | 73 | $this->eagerTable = $eagerTable.'.'; |
74 | 74 | } |
75 | 75 | |
@@ -87,12 +87,12 @@ discard block |
||
87 | 87 | // Store in cache |
88 | 88 | if ($fileToCompile->cached) |
89 | 89 | { |
90 | - File::copy(base_path('scaffolder-config/cache/' . $this->cachePrefix . $fileToCompile->hash . self::CACHE_EXT), $path); |
|
90 | + File::copy(base_path('scaffolder-config/cache/'.$this->cachePrefix.$fileToCompile->hash.self::CACHE_EXT), $path); |
|
91 | 91 | } |
92 | 92 | else |
93 | 93 | { |
94 | - File::put(base_path('scaffolder-config/cache/' . $this->cachePrefix . $fileToCompile->hash . self::CACHE_EXT), $this->stub); |
|
95 | - File::copy(base_path('scaffolder-config/cache/' . $this->cachePrefix . $fileToCompile->hash . self::CACHE_EXT), $path); |
|
94 | + File::put(base_path('scaffolder-config/cache/'.$this->cachePrefix.$fileToCompile->hash.self::CACHE_EXT), $this->stub); |
|
95 | + File::copy(base_path('scaffolder-config/cache/'.$this->cachePrefix.$fileToCompile->hash.self::CACHE_EXT), $path); |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | return $path; |
@@ -121,27 +121,27 @@ discard block |
||
121 | 121 | return $this; |
122 | 122 | } |
123 | 123 | |
124 | - protected function getPrimaryKeyField(){ |
|
124 | + protected function getPrimaryKeyField() { |
|
125 | 125 | $primaryKey = new stdClass; |
126 | - $primaryKey->name = "id" ; |
|
127 | - $primaryKey->index = "primary" ; |
|
128 | - $primaryKey->declared = false ; |
|
129 | - $primaryKey->type = new stdClass ; |
|
130 | - $primaryKey->type->ui = 'label' ; |
|
131 | - $primaryKey->type->db = 'integer' ; |
|
126 | + $primaryKey->name = "id"; |
|
127 | + $primaryKey->index = "primary"; |
|
128 | + $primaryKey->declared = false; |
|
129 | + $primaryKey->type = new stdClass; |
|
130 | + $primaryKey->type->ui = 'label'; |
|
131 | + $primaryKey->type->db = 'integer'; |
|
132 | 132 | $primaryKey->foreignKey = []; |
133 | - $primaryKey->validations = "required" ; |
|
133 | + $primaryKey->validations = "required"; |
|
134 | 134 | |
135 | 135 | foreach ($this->modelData->fields as $field) |
136 | 136 | { |
137 | 137 | if ($field->index == 'primary') |
138 | 138 | { |
139 | - $primaryKey = $field ; |
|
139 | + $primaryKey = $field; |
|
140 | 140 | break; |
141 | 141 | } |
142 | 142 | } |
143 | 143 | |
144 | - return $primaryKey ; |
|
144 | + return $primaryKey; |
|
145 | 145 | } |
146 | 146 | |
147 | 147 | /** |
@@ -190,14 +190,14 @@ discard block |
||
190 | 190 | * |
191 | 191 | * @return $this |
192 | 192 | */ |
193 | - protected function replaceForeingStrings($field, $originalStubPart){ |
|
193 | + protected function replaceForeingStrings($field, $originalStubPart) { |
|
194 | 194 | $replaceStub = str_replace('{{foreign_table}}', $field->foreignKey->table, $originalStubPart); |
195 | 195 | $replaceStub = str_replace('{{table_name}}', $this->modelData->tableName, $replaceStub); |
196 | 196 | $replaceStub = str_replace('{{foreign_field}}', $field->foreignKey->field, $replaceStub); |
197 | 197 | $replaceStub = str_replace('{{foreign_model}}', ucwords($field->foreignKey->table), $replaceStub); |
198 | 198 | $replaceStub = str_replace('{{field}}', $field->name, $replaceStub); |
199 | 199 | |
200 | - if(isset($this->scaffolderConfig->generator->namespaces)) |
|
200 | + if (isset($this->scaffolderConfig->generator->namespaces)) |
|
201 | 201 | $replaceStub = str_replace('{{model_namespace}}', $this->scaffolderConfig->generator->namespaces->models, $replaceStub); |
202 | 202 | |
203 | 203 | return $replaceStub; |
@@ -212,10 +212,10 @@ discard block |
||
212 | 212 | * |
213 | 213 | * @return $this |
214 | 214 | */ |
215 | - protected function replaceFieldStrings($field, $originalStubPart){ |
|
215 | + protected function replaceFieldStrings($field, $originalStubPart) { |
|
216 | 216 | $replaceStub = str_replace('{{field}}', $field->name, $originalStubPart); |
217 | 217 | |
218 | - if($this->eagerTable) $this->eagerTable.'.' ; |
|
218 | + if ($this->eagerTable) $this->eagerTable.'.'; |
|
219 | 219 | |
220 | 220 | $replaceStub = str_replace('{{eager_table}}', $this->eagerTable, $replaceStub); |
221 | 221 | |
@@ -243,14 +243,14 @@ discard block |
||
243 | 243 | * @return $this |
244 | 244 | */ |
245 | 245 | protected $modelDataArray = []; |
246 | - protected function getModelData($tableName){ |
|
246 | + protected function getModelData($tableName) { |
|
247 | 247 | |
248 | - if(array_key_exists($tableName, $this->modelDataArray)){ |
|
248 | + if (array_key_exists($tableName, $this->modelDataArray)) { |
|
249 | 249 | return $this->modelDataArray[$tableName]; |
250 | 250 | } |
251 | 251 | else { |
252 | 252 | |
253 | - $modelFilename = base_path('scaffolder-config/models/') . $tableName . '.json' ; |
|
253 | + $modelFilename = base_path('scaffolder-config/models/').$tableName.'.json'; |
|
254 | 254 | |
255 | 255 | $modelData = Json::decodeFile($modelFilename); |
256 | 256 | |
@@ -261,10 +261,10 @@ discard block |
||
261 | 261 | $modelHash = md5_file($modelFilename); |
262 | 262 | |
263 | 263 | // Set model name |
264 | - $modelData->modelName = $modelName ; |
|
264 | + $modelData->modelName = $modelName; |
|
265 | 265 | |
266 | 266 | // Set model name |
267 | - $modelData->modelHash = $modelHash ; |
|
267 | + $modelData->modelHash = $modelHash; |
|
268 | 268 | |
269 | 269 | $this->modelDataArray[$tableName] = $modelData; |
270 | 270 |
@@ -43,8 +43,7 @@ discard block |
||
43 | 43 | if (File::exists(base_path('scaffolder-config/cache/' . $this->cachePrefix . $this->modelData->modelHash . self::CACHE_EXT))) |
44 | 44 | { |
45 | 45 | return $this->store(new FileToCompile(true, $this->modelData->modelHash)); |
46 | - } |
|
47 | - else |
|
46 | + } else |
|
48 | 47 | { |
49 | 48 | |
50 | 49 | return $this->replacePrimaryKey() |
@@ -88,8 +87,7 @@ discard block |
||
88 | 87 | if ($fileToCompile->cached) |
89 | 88 | { |
90 | 89 | File::copy(base_path('scaffolder-config/cache/' . $this->cachePrefix . $fileToCompile->hash . self::CACHE_EXT), $path); |
91 | - } |
|
92 | - else |
|
90 | + } else |
|
93 | 91 | { |
94 | 92 | File::put(base_path('scaffolder-config/cache/' . $this->cachePrefix . $fileToCompile->hash . self::CACHE_EXT), $this->stub); |
95 | 93 | File::copy(base_path('scaffolder-config/cache/' . $this->cachePrefix . $fileToCompile->hash . self::CACHE_EXT), $path); |
@@ -197,8 +195,9 @@ discard block |
||
197 | 195 | $replaceStub = str_replace('{{foreign_model}}', ucwords($field->foreignKey->table), $replaceStub); |
198 | 196 | $replaceStub = str_replace('{{field}}', $field->name, $replaceStub); |
199 | 197 | |
200 | - if(isset($this->scaffolderConfig->generator->namespaces)) |
|
201 | - $replaceStub = str_replace('{{model_namespace}}', $this->scaffolderConfig->generator->namespaces->models, $replaceStub); |
|
198 | + if(isset($this->scaffolderConfig->generator->namespaces)) { |
|
199 | + $replaceStub = str_replace('{{model_namespace}}', $this->scaffolderConfig->generator->namespaces->models, $replaceStub); |
|
200 | + } |
|
202 | 201 | |
203 | 202 | return $replaceStub; |
204 | 203 | |
@@ -215,7 +214,9 @@ discard block |
||
215 | 214 | protected function replaceFieldStrings($field, $originalStubPart){ |
216 | 215 | $replaceStub = str_replace('{{field}}', $field->name, $originalStubPart); |
217 | 216 | |
218 | - if($this->eagerTable) $this->eagerTable.'.' ; |
|
217 | + if($this->eagerTable) { |
|
218 | + $this->eagerTable.'.' ; |
|
219 | + } |
|
219 | 220 | |
220 | 221 | $replaceStub = str_replace('{{eager_table}}', $this->eagerTable, $replaceStub); |
221 | 222 | |
@@ -247,8 +248,7 @@ discard block |
||
247 | 248 | |
248 | 249 | if(array_key_exists($tableName, $this->modelDataArray)){ |
249 | 250 | return $this->modelDataArray[$tableName]; |
250 | - } |
|
251 | - else { |
|
251 | + } else { |
|
252 | 252 | |
253 | 253 | $modelFilename = base_path('scaffolder-config/models/') . $tableName . '.json' ; |
254 | 254 |
@@ -8,13 +8,13 @@ discard block |
||
8 | 8 | Route::group(['prefix' => '{{route_prefix}}', 'middleware' => 'cors'], function () |
9 | 9 | { |
10 | 10 | |
11 | - Route::get('dashboard', function () |
|
12 | - { |
|
13 | - return view('dashboard'); |
|
14 | - }); |
|
11 | + Route::get('dashboard', function () |
|
12 | + { |
|
13 | + return view('dashboard'); |
|
14 | + }); |
|
15 | 15 | |
16 | - Route::match(['post'], 'upload', 'FileController@upload')->middleware('cors'); |
|
17 | - Route::get('upload', 'FileController@upload'); |
|
16 | + Route::match(['post'], 'upload', 'FileController@upload')->middleware('cors'); |
|
17 | + Route::get('upload', 'FileController@upload'); |
|
18 | 18 | |
19 | 19 | {{routes}} |
20 | 20 | }); |
@@ -22,14 +22,14 @@ discard block |
||
22 | 22 | # todo fix in the correct manner |
23 | 23 | // font fix issues |
24 | 24 | Route::get('/styles/ui-grid.woff', function(){ |
25 | - return file_get_contents(base_path('public').'/fonts/ui-grid.woff'); |
|
25 | + return file_get_contents(base_path('public').'/fonts/ui-grid.woff'); |
|
26 | 26 | }); |
27 | 27 | |
28 | 28 | Route::get('/styles/ui-grid.ttf', function(){ |
29 | - return file_get_contents(base_path('public').'/fonts/ui-grid.ttf'); |
|
29 | + return file_get_contents(base_path('public').'/fonts/ui-grid.ttf'); |
|
30 | 30 | }); |
31 | 31 | |
32 | 32 | // other routes point for the dist html file |
33 | 33 | Route::any('{any}', function(){ |
34 | - return file_get_contents(base_path('public').'/index.html'); |
|
34 | + return file_get_contents(base_path('public').'/index.html'); |
|
35 | 35 | })->where('any', '.*'); |
36 | 36 | \ No newline at end of file |
@@ -5,10 +5,10 @@ discard block |
||
5 | 5 | |-------------------------------------------------------------------------- |
6 | 6 | */ |
7 | 7 | |
8 | -Route::group(['prefix' => '{{route_prefix}}', 'middleware' => 'cors'], function () |
|
8 | +Route::group(['prefix' => '{{route_prefix}}', 'middleware' => 'cors'], function() |
|
9 | 9 | { |
10 | 10 | |
11 | - Route::get('dashboard', function () |
|
11 | + Route::get('dashboard', function() |
|
12 | 12 | { |
13 | 13 | return view('dashboard'); |
14 | 14 | }); |
@@ -21,15 +21,15 @@ discard block |
||
21 | 21 | |
22 | 22 | # todo fix in the correct manner |
23 | 23 | // font fix issues |
24 | -Route::get('/styles/ui-grid.woff', function(){ |
|
24 | +Route::get('/styles/ui-grid.woff', function() { |
|
25 | 25 | return file_get_contents(base_path('public').'/fonts/ui-grid.woff'); |
26 | 26 | }); |
27 | 27 | |
28 | -Route::get('/styles/ui-grid.ttf', function(){ |
|
28 | +Route::get('/styles/ui-grid.ttf', function() { |
|
29 | 29 | return file_get_contents(base_path('public').'/fonts/ui-grid.ttf'); |
30 | 30 | }); |
31 | 31 | |
32 | 32 | // other routes point for the dist html file |
33 | -Route::any('{any}', function(){ |
|
33 | +Route::any('{any}', function() { |
|
34 | 34 | return file_get_contents(base_path('public').'/index.html'); |
35 | 35 | })->where('any', '.*'); |
36 | 36 | \ No newline at end of file |
@@ -15,56 +15,56 @@ |
||
15 | 15 | |
16 | 16 | class {{class_name}}Controller extends Controller |
17 | 17 | { |
18 | - // blade views |
|
19 | - // index view |
|
18 | + // blade views |
|
19 | + // index view |
|
20 | 20 | |
21 | - public function show($id) |
|
22 | - { |
|
23 | - $file = {{class_name}}Model::find($id); |
|
24 | - return $file ; |
|
25 | - } |
|
21 | + public function show($id) |
|
22 | + { |
|
23 | + $file = {{class_name}}Model::find($id); |
|
24 | + return $file ; |
|
25 | + } |
|
26 | 26 | |
27 | - public function upload() |
|
28 | - { |
|
29 | - $config = new FlowConfig(); |
|
30 | - $config->setTempDir(storage_path() . '/tmp'); |
|
31 | - $config->setDeleteChunksOnSave(true); |
|
27 | + public function upload() |
|
28 | + { |
|
29 | + $config = new FlowConfig(); |
|
30 | + $config->setTempDir(storage_path() . '/tmp'); |
|
31 | + $config->setDeleteChunksOnSave(true); |
|
32 | 32 | |
33 | - $request = new FlowRequest(); |
|
33 | + $request = new FlowRequest(); |
|
34 | 34 | |
35 | - $totalSize = $request->getTotalSize(); |
|
35 | + $totalSize = $request->getTotalSize(); |
|
36 | 36 | |
37 | - if ($totalSize && $totalSize > (1024 * 1024 * 4)) |
|
38 | - { |
|
39 | - return $this->responseWithError('File size exceeds 4MB'); |
|
40 | - } |
|
37 | + if ($totalSize && $totalSize > (1024 * 1024 * 4)) |
|
38 | + { |
|
39 | + return $this->responseWithError('File size exceeds 4MB'); |
|
40 | + } |
|
41 | 41 | |
42 | - $requestFile = $request->getFile(); |
|
42 | + $requestFile = $request->getFile(); |
|
43 | 43 | |
44 | - $file = new ScaffolderFile($config, $request); |
|
44 | + $file = new ScaffolderFile($config, $request); |
|
45 | 45 | |
46 | - if ($file->validateChunk()) { |
|
47 | - $file->saveChunk(); |
|
48 | - } |
|
46 | + if ($file->validateChunk()) { |
|
47 | + $file->saveChunk(); |
|
48 | + } |
|
49 | 49 | |
50 | - if ($file->save(storage_path() . '/tmp/' . $request->getFileName())) |
|
51 | - { |
|
52 | - $file = FileModel::create([ |
|
53 | - 'mime_type' => $requestFile['type'], |
|
54 | - 'size' => $requestFile['size'], |
|
55 | - 'file_path' => storage_path() . '/tmp/', |
|
56 | - 'filename' => $requestFile['name'], |
|
57 | - 'disk' => 'local', |
|
58 | - 'status' => false, |
|
59 | - ]); |
|
50 | + if ($file->save(storage_path() . '/tmp/' . $request->getFileName())) |
|
51 | + { |
|
52 | + $file = FileModel::create([ |
|
53 | + 'mime_type' => $requestFile['type'], |
|
54 | + 'size' => $requestFile['size'], |
|
55 | + 'file_path' => storage_path() . '/tmp/', |
|
56 | + 'filename' => $requestFile['name'], |
|
57 | + 'disk' => 'local', |
|
58 | + 'status' => false, |
|
59 | + ]); |
|
60 | 60 | |
61 | - return $file->id; |
|
62 | - } |
|
63 | - else |
|
64 | - { |
|
65 | - // Indicate that we are not done with all the chunks. |
|
66 | - return null; |
|
67 | - } |
|
68 | - } |
|
61 | + return $file->id; |
|
62 | + } |
|
63 | + else |
|
64 | + { |
|
65 | + // Indicate that we are not done with all the chunks. |
|
66 | + return null; |
|
67 | + } |
|
68 | + } |
|
69 | 69 | |
70 | 70 | } |
@@ -5,7 +5,7 @@ discard block |
||
5 | 5 | use Illuminate\Http\Request; |
6 | 6 | use Illuminate\Pagination\Paginator; |
7 | 7 | use App\Http\Controllers\Controller; |
8 | -use App\Models\{{class_name}} as {{class_name}}Model;; |
|
8 | +use App\Models\{{class_name}} as {{class_name}}Model; ; |
|
9 | 9 | use App\Http\Controllers\File as ScaffolderFile; |
10 | 10 | use Log; |
11 | 11 | use Flow\Config as FlowConfig; |
@@ -21,13 +21,13 @@ discard block |
||
21 | 21 | public function show($id) |
22 | 22 | { |
23 | 23 | $file = {{class_name}}Model::find($id); |
24 | - return $file ; |
|
24 | + return $file; |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | public function upload() |
28 | 28 | { |
29 | 29 | $config = new FlowConfig(); |
30 | - $config->setTempDir(storage_path() . '/tmp'); |
|
30 | + $config->setTempDir(storage_path().'/tmp'); |
|
31 | 31 | $config->setDeleteChunksOnSave(true); |
32 | 32 | |
33 | 33 | $request = new FlowRequest(); |
@@ -47,12 +47,12 @@ discard block |
||
47 | 47 | $file->saveChunk(); |
48 | 48 | } |
49 | 49 | |
50 | - if ($file->save(storage_path() . '/tmp/' . $request->getFileName())) |
|
50 | + if ($file->save(storage_path().'/tmp/'.$request->getFileName())) |
|
51 | 51 | { |
52 | 52 | $file = FileModel::create([ |
53 | 53 | 'mime_type' => $requestFile['type'], |
54 | 54 | 'size' => $requestFile['size'], |
55 | - 'file_path' => storage_path() . '/tmp/', |
|
55 | + 'file_path' => storage_path().'/tmp/', |
|
56 | 56 | 'filename' => $requestFile['name'], |
57 | 57 | 'disk' => 'local', |
58 | 58 | 'status' => false, |
@@ -59,8 +59,7 @@ |
||
59 | 59 | ]); |
60 | 60 | |
61 | 61 | return $file->id; |
62 | - } |
|
63 | - else |
|
62 | + } else |
|
64 | 63 | { |
65 | 64 | // Indicate that we are not done with all the chunks. |
66 | 65 | return null; |
@@ -14,30 +14,30 @@ discard block |
||
14 | 14 | |
15 | 15 | class {{class_name}}Controller extends Controller |
16 | 16 | { |
17 | - // blade views |
|
18 | - // index view |
|
19 | - public function index() |
|
20 | - { |
|
21 | - return view('{{class_name_lw}}.index'); |
|
22 | - } |
|
23 | - // create view |
|
24 | - public function create() |
|
25 | - { |
|
26 | - return view('{{class_name_lw}}.create'); |
|
27 | - } |
|
28 | - |
|
29 | - // edit view |
|
30 | - public function edit($id) |
|
31 | - { |
|
32 | - ${{class_name_lw}} = {{class_name}}::find($id); |
|
33 | - |
|
34 | - return view('{{class_name_lw}}.edit')->with('model', ${{class_name_lw}}); |
|
35 | - } |
|
36 | - |
|
37 | - // api resources |
|
17 | + // blade views |
|
18 | + // index view |
|
19 | + public function index() |
|
20 | + { |
|
21 | + return view('{{class_name_lw}}.index'); |
|
22 | + } |
|
23 | + // create view |
|
24 | + public function create() |
|
25 | + { |
|
26 | + return view('{{class_name_lw}}.create'); |
|
27 | + } |
|
28 | + |
|
29 | + // edit view |
|
30 | + public function edit($id) |
|
31 | + { |
|
32 | + ${{class_name_lw}} = {{class_name}}::find($id); |
|
33 | + |
|
34 | + return view('{{class_name_lw}}.edit')->with('model', ${{class_name_lw}}); |
|
35 | + } |
|
36 | + |
|
37 | + // api resources |
|
38 | 38 | |
39 | - // save {{class_name_lw}} |
|
40 | - /*public function store(Request $request) |
|
39 | + // save {{class_name_lw}} |
|
40 | + /*public function store(Request $request) |
|
41 | 41 | { |
42 | 42 | // validate {{class_name_lw}} and eager objects |
43 | 43 | $this->validate($request, $this->getRules()); |
@@ -55,20 +55,20 @@ discard block |
||
55 | 55 | return ${{class_name_lw}} ; |
56 | 56 | }*/ |
57 | 57 | |
58 | - // save {{class_name_lw}} |
|
59 | - public function store(Request $request) |
|
60 | - { |
|
61 | - // validate {{class_name_lw}} and eager objects |
|
62 | - $this->validate($request, $this->getRules()); |
|
58 | + // save {{class_name_lw}} |
|
59 | + public function store(Request $request) |
|
60 | + { |
|
61 | + // validate {{class_name_lw}} and eager objects |
|
62 | + $this->validate($request, $this->getRules()); |
|
63 | 63 | |
64 | - $model = new {{class_name}}(); |
|
64 | + $model = new {{class_name}}(); |
|
65 | 65 | |
66 | - ${{class_name_lw}} = $model->store($request); |
|
66 | + ${{class_name_lw}} = $model->store($request); |
|
67 | 67 | |
68 | - return ${{class_name_lw}}; |
|
69 | - } |
|
68 | + return ${{class_name_lw}}; |
|
69 | + } |
|
70 | 70 | |
71 | - /*// update {{class_name_lw}} by id |
|
71 | + /*// update {{class_name_lw}} by id |
|
72 | 72 | public function update($id, Request $request) |
73 | 73 | { |
74 | 74 | // get vars |
@@ -89,45 +89,45 @@ discard block |
||
89 | 89 | {{relationship_tables_call}} |
90 | 90 | return ${{class_name_lw}}; |
91 | 91 | }*/ |
92 | - public function update($id, Request $request) |
|
93 | - { |
|
94 | - // validate {{table_name}} and eager objects |
|
95 | - $this->validate($request, $this->getRules($id)); |
|
92 | + public function update($id, Request $request) |
|
93 | + { |
|
94 | + // validate {{table_name}} and eager objects |
|
95 | + $this->validate($request, $this->getRules($id)); |
|
96 | 96 | |
97 | - $model = new {{class_name}}(); |
|
98 | - ${{class_name_lw}} = $model->updateModel($id, $request); |
|
97 | + $model = new {{class_name}}(); |
|
98 | + ${{class_name_lw}} = $model->updateModel($id, $request); |
|
99 | 99 | |
100 | - return ${{class_name_lw}}; |
|
101 | - } |
|
100 | + return ${{class_name_lw}}; |
|
101 | + } |
|
102 | 102 | |
103 | 103 | |
104 | - /*// get {{class_name_lw}} by id |
|
104 | + /*// get {{class_name_lw}} by id |
|
105 | 105 | public function show($id) |
106 | 106 | { |
107 | 107 | ${{class_name_lw}} = {{class_name}}::find($id); |
108 | 108 | return ${{class_name_lw}} ; |
109 | 109 | }*/ |
110 | - public function show($id) |
|
111 | - { |
|
112 | - $model = new {{class_name}}(); |
|
113 | - ${{class_name_lw}} = $model->show($id); |
|
114 | - return ${{class_name_lw}} ; |
|
115 | - } |
|
116 | - |
|
117 | - /*// find first by field and value |
|
110 | + public function show($id) |
|
111 | + { |
|
112 | + $model = new {{class_name}}(); |
|
113 | + ${{class_name_lw}} = $model->show($id); |
|
114 | + return ${{class_name_lw}} ; |
|
115 | + } |
|
116 | + |
|
117 | + /*// find first by field and value |
|
118 | 118 | public function findByField(Request $request) |
119 | 119 | { |
120 | 120 | ${{class_name_lw}} = {{class_name}}::where($request->input('field') , '=', $request->input('value'))->first(); |
121 | 121 | return ${{class_name_lw}} ; |
122 | 122 | }*/ |
123 | - public function findByField(Request $request) |
|
124 | - { |
|
125 | - $model = new {{class_name}}(); |
|
126 | - ${{class_name_lw}} = $model->findByField($request); |
|
127 | - return ${{class_name_lw}} ; |
|
128 | - } |
|
129 | - |
|
130 | - /*// build all validation rules |
|
123 | + public function findByField(Request $request) |
|
124 | + { |
|
125 | + $model = new {{class_name}}(); |
|
126 | + ${{class_name_lw}} = $model->findByField($request); |
|
127 | + return ${{class_name_lw}} ; |
|
128 | + } |
|
129 | + |
|
130 | + /*// build all validation rules |
|
131 | 131 | protected function getRules($id = null){ |
132 | 132 | // default object rules |
133 | 133 | $rules = {{class_name}}::$rules; |
@@ -138,19 +138,19 @@ discard block |
||
138 | 138 | |
139 | 139 | return $rules; |
140 | 140 | }*/ |
141 | - protected function getRules($id = null){ |
|
142 | - // default object rules |
|
143 | - $model = new {{class_name}}(); |
|
144 | - $rules = $model::$rules; |
|
145 | - ${{class_name_lw}} = $model->show($id); |
|
146 | - {{unique_rules}} |
|
147 | - // nested rules for eager objects |
|
148 | - {{rules_eager}} |
|
141 | + protected function getRules($id = null){ |
|
142 | + // default object rules |
|
143 | + $model = new {{class_name}}(); |
|
144 | + $rules = $model::$rules; |
|
145 | + ${{class_name_lw}} = $model->show($id); |
|
146 | + {{unique_rules}} |
|
147 | + // nested rules for eager objects |
|
148 | + {{rules_eager}} |
|
149 | 149 | |
150 | - return $rules; |
|
151 | - } |
|
150 | + return $rules; |
|
151 | + } |
|
152 | 152 | |
153 | - /*// delete model by id |
|
153 | + /*// delete model by id |
|
154 | 154 | public function destroy($id) |
155 | 155 | { |
156 | 156 | $ids = explode(",", $id); |
@@ -164,32 +164,32 @@ discard block |
||
164 | 164 | |
165 | 165 | return json_encode($status); |
166 | 166 | }*/ |
167 | - public function destroy($id) |
|
168 | - { |
|
169 | - $ids = explode(",", $id); |
|
170 | - $ids = array_unique($ids); |
|
167 | + public function destroy($id) |
|
168 | + { |
|
169 | + $ids = explode(",", $id); |
|
170 | + $ids = array_unique($ids); |
|
171 | 171 | |
172 | - $model = new {{class_name}}(); |
|
172 | + $model = new {{class_name}}(); |
|
173 | 173 | |
174 | - $success = $model->destroy($ids); |
|
174 | + $success = $model->destroy($ids); |
|
175 | 175 | |
176 | - $status = array("error" => true, "message" => "Error deleting object"); |
|
177 | - if ($success) |
|
178 | - $status = array("error" => false, "message" => "Object successfully deleted"); |
|
176 | + $status = array("error" => true, "message" => "Error deleting object"); |
|
177 | + if ($success) |
|
178 | + $status = array("error" => false, "message" => "Object successfully deleted"); |
|
179 | 179 | |
180 | - return json_encode($status); |
|
180 | + return json_encode($status); |
|
181 | 181 | |
182 | - } |
|
182 | + } |
|
183 | 183 | |
184 | - {{reverseRelationships}} |
|
185 | - {{relationship_tables_store}} |
|
186 | - {{remove_relationship_objects}} |
|
187 | - {{enum}} |
|
188 | - {{checkbox}} |
|
184 | + {{reverseRelationships}} |
|
185 | + {{relationship_tables_store}} |
|
186 | + {{remove_relationship_objects}} |
|
187 | + {{enum}} |
|
188 | + {{checkbox}} |
|
189 | 189 | |
190 | 190 | |
191 | - // query with search and pagination options |
|
192 | - /*public function query(Request $request) |
|
191 | + // query with search and pagination options |
|
192 | + /*public function query(Request $request) |
|
193 | 193 | { |
194 | 194 | // get query parameters |
195 | 195 | $params = $request->all(); |
@@ -238,20 +238,20 @@ discard block |
||
238 | 238 | return $query->paginate($pagination["itensPerPage"]); |
239 | 239 | }*/ |
240 | 240 | |
241 | - // query with search and pagination options |
|
242 | - public function query(Request $request) |
|
243 | - { |
|
244 | - $model = new {{class_name}}(); |
|
241 | + // query with search and pagination options |
|
242 | + public function query(Request $request) |
|
243 | + { |
|
244 | + $model = new {{class_name}}(); |
|
245 | 245 | |
246 | - $query = $model->querySearch($request); |
|
246 | + $query = $model->querySearch($request); |
|
247 | 247 | |
248 | - return $query; |
|
249 | - } |
|
248 | + return $query; |
|
249 | + } |
|
250 | 250 | |
251 | 251 | |
252 | - // query with fields filters and pagination |
|
253 | - //json = {"pagination": {"actual": 1, "itensPerPage": 20}, "fields": ["name","email","cnpj"], "orderBy": "name"} |
|
254 | - /*public function queryFilters(Request $request) |
|
252 | + // query with fields filters and pagination |
|
253 | + //json = {"pagination": {"actual": 1, "itensPerPage": 20}, "fields": ["name","email","cnpj"], "orderBy": "name"} |
|
254 | + /*public function queryFilters(Request $request) |
|
255 | 255 | { |
256 | 256 | // get query parameters |
257 | 257 | $params = $request->all(); |
@@ -311,16 +311,16 @@ discard block |
||
311 | 311 | |
312 | 312 | return ${{class_name_lw}}->paginate($pagination["itensPerPage"]); |
313 | 313 | }*/ |
314 | - // query with fields filters and pagination |
|
315 | - //json = {"pagination": {"actual": 1, "itensPerPage": 20}, "fields": ["name","email","cnpj"], "orderBy": "name"} |
|
316 | - public function queryFilters(Request $request) |
|
317 | - { |
|
318 | - $model = new {{class_name}}(); |
|
314 | + // query with fields filters and pagination |
|
315 | + //json = {"pagination": {"actual": 1, "itensPerPage": 20}, "fields": ["name","email","cnpj"], "orderBy": "name"} |
|
316 | + public function queryFilters(Request $request) |
|
317 | + { |
|
318 | + $model = new {{class_name}}(); |
|
319 | 319 | |
320 | - ${{class_name_lw}} = $model->queryFilters($request); |
|
320 | + ${{class_name_lw}} = $model->queryFilters($request); |
|
321 | 321 | |
322 | - return ${{class_name_lw}}; |
|
323 | - } |
|
322 | + return ${{class_name_lw}}; |
|
323 | + } |
|
324 | 324 | |
325 | 325 | |
326 | 326 | } |
@@ -138,7 +138,7 @@ |
||
138 | 138 | |
139 | 139 | return $rules; |
140 | 140 | }*/ |
141 | - protected function getRules($id = null){ |
|
141 | + protected function getRules($id = null) { |
|
142 | 142 | // default object rules |
143 | 143 | $model = new {{class_name}}(); |
144 | 144 | $rules = $model::$rules; |
@@ -174,8 +174,9 @@ |
||
174 | 174 | $success = $model->destroy($ids); |
175 | 175 | |
176 | 176 | $status = array("error" => true, "message" => "Error deleting object"); |
177 | - if ($success) |
|
178 | - $status = array("error" => false, "message" => "Object successfully deleted"); |
|
177 | + if ($success) { |
|
178 | + $status = array("error" => false, "message" => "Object successfully deleted"); |
|
179 | + } |
|
179 | 180 | |
180 | 181 | return json_encode($status); |
181 | 182 |
@@ -13,209 +13,209 @@ |
||
13 | 13 | |
14 | 14 | class {{class_name}} extends Model |
15 | 15 | { |
16 | - /** |
|
17 | - * The database table used by the model. |
|
18 | - * |
|
19 | - * @var string |
|
20 | - */ |
|
21 | - protected $table = '{{table_name}}'; |
|
22 | - {{timestamps}} |
|
23 | - |
|
24 | - {{primaryAttribute}} |
|
25 | - public $fillable = [ |
|
26 | - {{fillable}} |
|
27 | - ]; |
|
28 | - |
|
29 | - // validation rules |
|
30 | - public static $rules = [ |
|
31 | - {{validations}} |
|
32 | - ]; |
|
33 | - |
|
34 | - // eager loading objects |
|
35 | - public $with = [ |
|
36 | - {{eager}} |
|
37 | - ]; |
|
38 | - |
|
39 | - {{enum}} |
|
40 | - |
|
41 | - {{belongsTo}} |
|
42 | - |
|
43 | - {{reverseRelationship}} |
|
16 | + /** |
|
17 | + * The database table used by the model. |
|
18 | + * |
|
19 | + * @var string |
|
20 | + */ |
|
21 | + protected $table = '{{table_name}}'; |
|
22 | + {{timestamps}} |
|
23 | + |
|
24 | + {{primaryAttribute}} |
|
25 | + public $fillable = [ |
|
26 | + {{fillable}} |
|
27 | + ]; |
|
28 | + |
|
29 | + // validation rules |
|
30 | + public static $rules = [ |
|
31 | + {{validations}} |
|
32 | + ]; |
|
33 | + |
|
34 | + // eager loading objects |
|
35 | + public $with = [ |
|
36 | + {{eager}} |
|
37 | + ]; |
|
38 | + |
|
39 | + {{enum}} |
|
40 | + |
|
41 | + {{belongsTo}} |
|
42 | + |
|
43 | + {{reverseRelationship}} |
|
44 | 44 | |
45 | 45 | |
46 | - //api resources |
|
46 | + //api resources |
|
47 | 47 | |
48 | 48 | |
49 | 49 | |
50 | - // save {{class_name_lw}} |
|
51 | - public function store(Request $request) |
|
52 | - { |
|
53 | - $vars = $request->all(); |
|
50 | + // save {{class_name_lw}} |
|
51 | + public function store(Request $request) |
|
52 | + { |
|
53 | + $vars = $request->all(); |
|
54 | 54 | |
55 | - //create eager objects |
|
56 | - {{store_eager_objects}} |
|
55 | + //create eager objects |
|
56 | + {{store_eager_objects}} |
|
57 | 57 | |
58 | - ${{class_name_lw}} = {{class_name}}::create($vars); |
|
58 | + ${{class_name_lw}} = {{class_name}}::create($vars); |
|
59 | 59 | |
60 | - //create relationship_tables objects |
|
61 | - {{relationship_tables_call}} |
|
60 | + //create relationship_tables objects |
|
61 | + {{relationship_tables_call}} |
|
62 | 62 | |
63 | - return ${{class_name_lw}} ; |
|
64 | - } |
|
63 | + return ${{class_name_lw}} ; |
|
64 | + } |
|
65 | 65 | |
66 | 66 | |
67 | - // get {{class_name_lw}} by id |
|
68 | - public function show($id) |
|
69 | - { |
|
70 | - ${{class_name_lw}} = {{class_name}}::find($id); |
|
71 | - return ${{class_name_lw}}; |
|
72 | - } |
|
67 | + // get {{class_name_lw}} by id |
|
68 | + public function show($id) |
|
69 | + { |
|
70 | + ${{class_name_lw}} = {{class_name}}::find($id); |
|
71 | + return ${{class_name_lw}}; |
|
72 | + } |
|
73 | 73 | |
74 | 74 | |
75 | 75 | |
76 | - //get first row by field and value |
|
77 | - public function findByField(Request $request) |
|
78 | - { |
|
79 | - ${{class_name_lw}} = {{class_name}}::where($request->input('field') , '=', $request->input('value'))->first(); |
|
80 | - return ${{class_name_lw}} ; |
|
81 | - } |
|
76 | + //get first row by field and value |
|
77 | + public function findByField(Request $request) |
|
78 | + { |
|
79 | + ${{class_name_lw}} = {{class_name}}::where($request->input('field') , '=', $request->input('value'))->first(); |
|
80 | + return ${{class_name_lw}} ; |
|
81 | + } |
|
82 | 82 | |
83 | 83 | |
84 | - // update {{class_name_lw}} by id |
|
85 | - public function updateModel($id, Request $request) |
|
86 | - { |
|
87 | - // get vars |
|
88 | - $vars = $request->all(); |
|
84 | + // update {{class_name_lw}} by id |
|
85 | + public function updateModel($id, Request $request) |
|
86 | + { |
|
87 | + // get vars |
|
88 | + $vars = $request->all(); |
|
89 | 89 | |
90 | - //update eager objects |
|
91 | - {{update_eager_objects}} |
|
90 | + //update eager objects |
|
91 | + {{update_eager_objects}} |
|
92 | 92 | |
93 | - ${{class_name_lw}} = {{class_name}}::find($id); |
|
94 | - ${{class_name_lw}}->fill($vars); |
|
95 | - ${{class_name_lw}}->save(); |
|
93 | + ${{class_name_lw}} = {{class_name}}::find($id); |
|
94 | + ${{class_name_lw}}->fill($vars); |
|
95 | + ${{class_name_lw}}->save(); |
|
96 | 96 | |
97 | - //update relationship_tables objects |
|
98 | - {{remove_relationship_objects_call}} |
|
97 | + //update relationship_tables objects |
|
98 | + {{remove_relationship_objects_call}} |
|
99 | 99 | |
100 | - {{relationship_tables_call}} |
|
100 | + {{relationship_tables_call}} |
|
101 | 101 | |
102 | - return ${{class_name_lw}}; |
|
103 | - } |
|
102 | + return ${{class_name_lw}}; |
|
103 | + } |
|
104 | 104 | |
105 | 105 | |
106 | - // delete model by id or ids |
|
107 | - public static function destroy($ids) |
|
108 | - { |
|
109 | - $success = {{class_name}}::whereIn('id', $ids)->delete(); |
|
106 | + // delete model by id or ids |
|
107 | + public static function destroy($ids) |
|
108 | + { |
|
109 | + $success = {{class_name}}::whereIn('id', $ids)->delete(); |
|
110 | 110 | |
111 | - return $success; |
|
112 | - } |
|
113 | - |
|
114 | - // query with search and pagination options |
|
115 | - public function querySearch(Request $request) |
|
116 | - { |
|
117 | - // get query parameters |
|
118 | - $params = $request->all(); |
|
119 | - |
|
120 | - // get pagination conditions |
|
121 | - if(isset($params["pagination"])) { |
|
122 | - $pagination = $params["pagination"]; |
|
123 | - } |
|
124 | - else { // set default |
|
125 | - $pagination = ["actual" => 1, "itensPerPage" => 25 ] ; |
|
126 | - } |
|
127 | - |
|
128 | - // resolve current page |
|
129 | - $currentPage = $pagination["actual"]; |
|
130 | - Paginator::currentPageResolver(function () use ($currentPage) { |
|
131 | - return $currentPage; |
|
132 | - }); |
|
133 | - |
|
134 | - // set first condition 1=1 (all results) |
|
135 | - $query = {{class_name}}::WhereNotNull('{{table_name}}.{{primary_key}}'); |
|
136 | - |
|
137 | - // get filters conditions |
|
138 | - $filters = isset($params["filters"]) ? $params["filters"] : $params; |
|
111 | + return $success; |
|
112 | + } |
|
113 | + |
|
114 | + // query with search and pagination options |
|
115 | + public function querySearch(Request $request) |
|
116 | + { |
|
117 | + // get query parameters |
|
118 | + $params = $request->all(); |
|
119 | + |
|
120 | + // get pagination conditions |
|
121 | + if(isset($params["pagination"])) { |
|
122 | + $pagination = $params["pagination"]; |
|
123 | + } |
|
124 | + else { // set default |
|
125 | + $pagination = ["actual" => 1, "itensPerPage" => 25 ] ; |
|
126 | + } |
|
127 | + |
|
128 | + // resolve current page |
|
129 | + $currentPage = $pagination["actual"]; |
|
130 | + Paginator::currentPageResolver(function () use ($currentPage) { |
|
131 | + return $currentPage; |
|
132 | + }); |
|
133 | + |
|
134 | + // set first condition 1=1 (all results) |
|
135 | + $query = {{class_name}}::WhereNotNull('{{table_name}}.{{primary_key}}'); |
|
136 | + |
|
137 | + // get filters conditions |
|
138 | + $filters = isset($params["filters"]) ? $params["filters"] : $params; |
|
139 | 139 | |
140 | - // field by field condition |
|
141 | - {{conditions}} |
|
140 | + // field by field condition |
|
141 | + {{conditions}} |
|
142 | 142 | |
143 | - // join eager objects |
|
144 | - {{eager_joins}} |
|
143 | + // join eager objects |
|
144 | + {{eager_joins}} |
|
145 | 145 | |
146 | - // eager object condition |
|
147 | - {{eager_conditions}} |
|
146 | + // eager object condition |
|
147 | + {{eager_conditions}} |
|
148 | 148 | |
149 | - // join relationship tables objects |
|
150 | - {{relationship_tables_joins}} |
|
151 | - // get sort clauses |
|
152 | - if(isset($params["sort"]) && count($params["sort"])) { |
|
153 | - foreach($params["sort"] as $sort){ |
|
154 | - {{relationship_tables_joins_sort}} |
|
155 | - $query->orderBy($sort["field"], $sort["order"]); |
|
156 | - } |
|
157 | - } |
|
149 | + // join relationship tables objects |
|
150 | + {{relationship_tables_joins}} |
|
151 | + // get sort clauses |
|
152 | + if(isset($params["sort"]) && count($params["sort"])) { |
|
153 | + foreach($params["sort"] as $sort){ |
|
154 | + {{relationship_tables_joins_sort}} |
|
155 | + $query->orderBy($sort["field"], $sort["order"]); |
|
156 | + } |
|
157 | + } |
|
158 | 158 | |
159 | 159 | |
160 | 160 | |
161 | - return $query->paginate($pagination["itensPerPage"]); |
|
162 | - } |
|
163 | - |
|
164 | - |
|
165 | - // query with fields filters and pagination |
|
166 | - //json = {"pagination": {"actual": 1, "itensPerPage": 20}, "fields": ["name","email","cnpj"], "orderBy": "name"} |
|
167 | - public function queryFilters(Request $request) |
|
168 | - { |
|
169 | - // get query parameters |
|
170 | - $params = $request->all(); |
|
171 | - |
|
172 | - $orderBy = '{{primary_key}}'; |
|
173 | - $fields = null; |
|
174 | - $selectArray = []; |
|
175 | - array_push($selectArray,'{{primary_key}}'); |
|
176 | - |
|
177 | - // get pagination conditions |
|
178 | - if(isset($params["pagination"])) { |
|
179 | - $pagination = $params["pagination"]; |
|
180 | - } |
|
181 | - else { // set default |
|
182 | - $pagination = ["actual" => 1, "itensPerPage" => 25 ] ; |
|
183 | - } |
|
184 | - |
|
185 | - // resolve current page |
|
186 | - $currentPage = $pagination["actual"]; |
|
187 | - Paginator::currentPageResolver(function () use ($currentPage) { |
|
188 | - return $currentPage; |
|
189 | - }); |
|
190 | - |
|
191 | - if(isset($params["fields"])) { |
|
192 | - $fields = $params["fields"]; |
|
193 | - |
|
194 | - foreach ($fields as $field) { |
|
195 | - if(Schema::hasColumn('{{table_name}}', $field)){ |
|
196 | - array_push($selectArray, $field); |
|
197 | - } |
|
198 | - } |
|
199 | - |
|
200 | - } |
|
201 | - |
|
202 | - if(isset($params["orderBy"])) { |
|
203 | - if(Schema::hasColumn('{{table_name}}',$params["orderBy"])){ |
|
204 | - $orderBy = $params["orderBy"]; |
|
205 | - } |
|
206 | - } |
|
207 | - |
|
208 | - ${{class_name_lw}} = {{class_name}}::WhereNotNull('{{table_name}}.{{primary_key}}'); |
|
209 | - |
|
210 | - ${{class_name_lw}}->select($selectArray)->orderBy($orderBy,'asc'); |
|
161 | + return $query->paginate($pagination["itensPerPage"]); |
|
162 | + } |
|
163 | + |
|
164 | + |
|
165 | + // query with fields filters and pagination |
|
166 | + //json = {"pagination": {"actual": 1, "itensPerPage": 20}, "fields": ["name","email","cnpj"], "orderBy": "name"} |
|
167 | + public function queryFilters(Request $request) |
|
168 | + { |
|
169 | + // get query parameters |
|
170 | + $params = $request->all(); |
|
171 | + |
|
172 | + $orderBy = '{{primary_key}}'; |
|
173 | + $fields = null; |
|
174 | + $selectArray = []; |
|
175 | + array_push($selectArray,'{{primary_key}}'); |
|
176 | + |
|
177 | + // get pagination conditions |
|
178 | + if(isset($params["pagination"])) { |
|
179 | + $pagination = $params["pagination"]; |
|
180 | + } |
|
181 | + else { // set default |
|
182 | + $pagination = ["actual" => 1, "itensPerPage" => 25 ] ; |
|
183 | + } |
|
184 | + |
|
185 | + // resolve current page |
|
186 | + $currentPage = $pagination["actual"]; |
|
187 | + Paginator::currentPageResolver(function () use ($currentPage) { |
|
188 | + return $currentPage; |
|
189 | + }); |
|
190 | + |
|
191 | + if(isset($params["fields"])) { |
|
192 | + $fields = $params["fields"]; |
|
193 | + |
|
194 | + foreach ($fields as $field) { |
|
195 | + if(Schema::hasColumn('{{table_name}}', $field)){ |
|
196 | + array_push($selectArray, $field); |
|
197 | + } |
|
198 | + } |
|
199 | + |
|
200 | + } |
|
201 | + |
|
202 | + if(isset($params["orderBy"])) { |
|
203 | + if(Schema::hasColumn('{{table_name}}',$params["orderBy"])){ |
|
204 | + $orderBy = $params["orderBy"]; |
|
205 | + } |
|
206 | + } |
|
207 | + |
|
208 | + ${{class_name_lw}} = {{class_name}}::WhereNotNull('{{table_name}}.{{primary_key}}'); |
|
209 | + |
|
210 | + ${{class_name_lw}}->select($selectArray)->orderBy($orderBy,'asc'); |
|
211 | 211 | |
212 | - return ${{class_name_lw}}->paginate($pagination["itensPerPage"]); |
|
213 | - } |
|
212 | + return ${{class_name_lw}}->paginate($pagination["itensPerPage"]); |
|
213 | + } |
|
214 | 214 | |
215 | 215 | |
216 | - {{relationship_tables_store}} |
|
216 | + {{relationship_tables_store}} |
|
217 | 217 | |
218 | - {{remove_relationship_objects}} |
|
218 | + {{remove_relationship_objects}} |
|
219 | 219 | |
220 | - {{checkbox}} |
|
220 | + {{checkbox}} |
|
221 | 221 | } |
222 | 222 | \ No newline at end of file |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | ]; |
28 | 28 | |
29 | 29 | // validation rules |
30 | - public static $rules = [ |
|
30 | + public static $rules = [ |
|
31 | 31 | {{validations}} |
32 | 32 | ]; |
33 | 33 | |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | //get first row by field and value |
77 | 77 | public function findByField(Request $request) |
78 | 78 | { |
79 | - ${{class_name_lw}} = {{class_name}}::where($request->input('field') , '=', $request->input('value'))->first(); |
|
79 | + ${{class_name_lw}} = {{class_name}}::where($request->input('field'), '=', $request->input('value'))->first(); |
|
80 | 80 | return ${{class_name_lw}} ; |
81 | 81 | } |
82 | 82 | |
@@ -118,16 +118,16 @@ discard block |
||
118 | 118 | $params = $request->all(); |
119 | 119 | |
120 | 120 | // get pagination conditions |
121 | - if(isset($params["pagination"])) { |
|
121 | + if (isset($params["pagination"])) { |
|
122 | 122 | $pagination = $params["pagination"]; |
123 | 123 | } |
124 | 124 | else { // set default |
125 | - $pagination = ["actual" => 1, "itensPerPage" => 25 ] ; |
|
125 | + $pagination = ["actual" => 1, "itensPerPage" => 25]; |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | // resolve current page |
129 | 129 | $currentPage = $pagination["actual"]; |
130 | - Paginator::currentPageResolver(function () use ($currentPage) { |
|
130 | + Paginator::currentPageResolver(function() use ($currentPage) { |
|
131 | 131 | return $currentPage; |
132 | 132 | }); |
133 | 133 | |
@@ -149,8 +149,8 @@ discard block |
||
149 | 149 | // join relationship tables objects |
150 | 150 | {{relationship_tables_joins}} |
151 | 151 | // get sort clauses |
152 | - if(isset($params["sort"]) && count($params["sort"])) { |
|
153 | - foreach($params["sort"] as $sort){ |
|
152 | + if (isset($params["sort"]) && count($params["sort"])) { |
|
153 | + foreach ($params["sort"] as $sort) { |
|
154 | 154 | {{relationship_tables_joins_sort}} |
155 | 155 | $query->orderBy($sort["field"], $sort["order"]); |
156 | 156 | } |
@@ -172,42 +172,42 @@ discard block |
||
172 | 172 | $orderBy = '{{primary_key}}'; |
173 | 173 | $fields = null; |
174 | 174 | $selectArray = []; |
175 | - array_push($selectArray,'{{primary_key}}'); |
|
175 | + array_push($selectArray, '{{primary_key}}'); |
|
176 | 176 | |
177 | 177 | // get pagination conditions |
178 | - if(isset($params["pagination"])) { |
|
178 | + if (isset($params["pagination"])) { |
|
179 | 179 | $pagination = $params["pagination"]; |
180 | 180 | } |
181 | 181 | else { // set default |
182 | - $pagination = ["actual" => 1, "itensPerPage" => 25 ] ; |
|
182 | + $pagination = ["actual" => 1, "itensPerPage" => 25]; |
|
183 | 183 | } |
184 | 184 | |
185 | 185 | // resolve current page |
186 | 186 | $currentPage = $pagination["actual"]; |
187 | - Paginator::currentPageResolver(function () use ($currentPage) { |
|
187 | + Paginator::currentPageResolver(function() use ($currentPage) { |
|
188 | 188 | return $currentPage; |
189 | 189 | }); |
190 | 190 | |
191 | - if(isset($params["fields"])) { |
|
191 | + if (isset($params["fields"])) { |
|
192 | 192 | $fields = $params["fields"]; |
193 | 193 | |
194 | 194 | foreach ($fields as $field) { |
195 | - if(Schema::hasColumn('{{table_name}}', $field)){ |
|
195 | + if (Schema::hasColumn('{{table_name}}', $field)) { |
|
196 | 196 | array_push($selectArray, $field); |
197 | 197 | } |
198 | 198 | } |
199 | 199 | |
200 | 200 | } |
201 | 201 | |
202 | - if(isset($params["orderBy"])) { |
|
203 | - if(Schema::hasColumn('{{table_name}}',$params["orderBy"])){ |
|
202 | + if (isset($params["orderBy"])) { |
|
203 | + if (Schema::hasColumn('{{table_name}}', $params["orderBy"])) { |
|
204 | 204 | $orderBy = $params["orderBy"]; |
205 | 205 | } |
206 | 206 | } |
207 | 207 | |
208 | 208 | ${{class_name_lw}} = {{class_name}}::WhereNotNull('{{table_name}}.{{primary_key}}'); |
209 | 209 | |
210 | - ${{class_name_lw}}->select($selectArray)->orderBy($orderBy,'asc'); |
|
210 | + ${{class_name_lw}}->select($selectArray)->orderBy($orderBy, 'asc'); |
|
211 | 211 | |
212 | 212 | return ${{class_name_lw}}->paginate($pagination["itensPerPage"]); |
213 | 213 | } |
@@ -120,8 +120,7 @@ discard block |
||
120 | 120 | // get pagination conditions |
121 | 121 | if(isset($params["pagination"])) { |
122 | 122 | $pagination = $params["pagination"]; |
123 | - } |
|
124 | - else { // set default |
|
123 | + } else { // set default |
|
125 | 124 | $pagination = ["actual" => 1, "itensPerPage" => 25 ] ; |
126 | 125 | } |
127 | 126 | |
@@ -177,8 +176,7 @@ discard block |
||
177 | 176 | // get pagination conditions |
178 | 177 | if(isset($params["pagination"])) { |
179 | 178 | $pagination = $params["pagination"]; |
180 | - } |
|
181 | - else { // set default |
|
179 | + } else { // set default |
|
182 | 180 | $pagination = ["actual" => 1, "itensPerPage" => 25 ] ; |
183 | 181 | } |
184 | 182 |
@@ -7,26 +7,26 @@ |
||
7 | 7 | |
8 | 8 | class {{class_name}} extends Model |
9 | 9 | { |
10 | - /** |
|
11 | - * The database table used by the model. |
|
12 | - * |
|
13 | - * @var string |
|
14 | - */ |
|
15 | - protected $table = '{{table_name}}'; |
|
10 | + /** |
|
11 | + * The database table used by the model. |
|
12 | + * |
|
13 | + * @var string |
|
14 | + */ |
|
15 | + protected $table = '{{table_name}}'; |
|
16 | 16 | |
17 | - {{primaryAttribute}} |
|
18 | - public $fillable = [ |
|
19 | - {{fillable}} |
|
20 | - ]; |
|
17 | + {{primaryAttribute}} |
|
18 | + public $fillable = [ |
|
19 | + {{fillable}} |
|
20 | + ]; |
|
21 | 21 | |
22 | - public static function boot() |
|
23 | - { |
|
24 | - parent::boot(); |
|
22 | + public static function boot() |
|
23 | + { |
|
24 | + parent::boot(); |
|
25 | 25 | |
26 | - static::deleting(function($model) |
|
27 | - { |
|
28 | - Storage::disk($model->disk)->delete($model->file_path); |
|
29 | - }); |
|
30 | - } |
|
26 | + static::deleting(function($model) |
|
27 | + { |
|
28 | + Storage::disk($model->disk)->delete($model->file_path); |
|
29 | + }); |
|
30 | + } |
|
31 | 31 | |
32 | 32 | } |
33 | 33 | \ No newline at end of file |
@@ -5,21 +5,21 @@ |
||
5 | 5 | |
6 | 6 | class Create{{class_name}}Table extends Migration |
7 | 7 | { |
8 | - /** |
|
9 | - * Run the migrations. |
|
10 | - */ |
|
11 | - public function up() |
|
12 | - { |
|
13 | - Schema::create('{{table_name}}', function (Blueprint $table) { |
|
8 | + /** |
|
9 | + * Run the migrations. |
|
10 | + */ |
|
11 | + public function up() |
|
12 | + { |
|
13 | + Schema::create('{{table_name}}', function (Blueprint $table) { |
|
14 | 14 | {{fields}} |
15 | - }); |
|
16 | - } |
|
15 | + }); |
|
16 | + } |
|
17 | 17 | |
18 | - /** |
|
19 | - * Reverse the migrations. |
|
20 | - */ |
|
21 | - public function down() |
|
22 | - { |
|
23 | - Schema::drop('{{table_name}}'); |
|
24 | - } |
|
18 | + /** |
|
19 | + * Reverse the migrations. |
|
20 | + */ |
|
21 | + public function down() |
|
22 | + { |
|
23 | + Schema::drop('{{table_name}}'); |
|
24 | + } |
|
25 | 25 | } |
@@ -3,14 +3,14 @@ |
||
3 | 3 | use Illuminate\Database\Schema\Blueprint; |
4 | 4 | use Illuminate\Database\Migrations\Migration; |
5 | 5 | |
6 | -class Create{{class_name}}Table extends Migration |
|
6 | +class Create {{class_name}}Table extends Migration |
|
7 | 7 | { |
8 | 8 | /** |
9 | 9 | * Run the migrations. |
10 | 10 | */ |
11 | 11 | public function up() |
12 | 12 | { |
13 | - Schema::create('{{table_name}}', function (Blueprint $table) { |
|
13 | + Schema::create('{{table_name}}', function(Blueprint $table) { |
|
14 | 14 | {{fields}} |
15 | 15 | }); |
16 | 16 | } |