@@ -47,10 +47,11 @@ |
||
47 | 47 | $itemGenerator = new $generator($module); |
48 | 48 | $returnedFiles = $itemGenerator->generate(); |
49 | 49 | |
50 | - if (!is_array($returnedFiles)) |
|
51 | - $generatedFiles[] = $returnedFiles; |
|
52 | - else |
|
53 | - $generatedFiles = array_merge($generatedFiles, $returnedFiles); |
|
50 | + if (!is_array($returnedFiles)) { |
|
51 | + $generatedFiles[] = $returnedFiles; |
|
52 | + } else { |
|
53 | + $generatedFiles = array_merge($generatedFiles, $returnedFiles); |
|
54 | + } |
|
54 | 55 | |
55 | 56 | $bar->advance(); |
56 | 57 | } |
@@ -73,7 +73,7 @@ |
||
73 | 73 | } |
74 | 74 | } |
75 | 75 | |
76 | - protected function configToGenerators($array){ |
|
76 | + protected function configToGenerators($array) { |
|
77 | 77 | $generators = []; |
78 | 78 | foreach ($array as $ns => $items) { |
79 | 79 | foreach ($items as $item) { |
@@ -51,10 +51,10 @@ discard block |
||
51 | 51 | } |
52 | 52 | |
53 | 53 | public function initializeFile($fullFilePath, $stub, $initializeWithText = false) { |
54 | - if(file_exists($fullFilePath)){ |
|
54 | + if (file_exists($fullFilePath)) { |
|
55 | 55 | $this->fileSystem->remove($fullFilePath); |
56 | 56 | } |
57 | - $seederTemplate = ($initializeWithText===false) ? $this->buildTemplate($stub) : $initializeWithText; |
|
57 | + $seederTemplate = ($initializeWithText === false) ? $this->buildTemplate($stub) : $initializeWithText; |
|
58 | 58 | $this->fileSystem->dumpFile($fullFilePath, $seederTemplate); |
59 | 59 | return $fullFilePath; |
60 | 60 | } |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | } |
77 | 77 | |
78 | 78 | public function insertIntoFile($file_path, $insert_marker, $text, $after = true) { |
79 | - $contents = str_replace("\r",'', file_get_contents($file_path)); |
|
79 | + $contents = str_replace("\r", '', file_get_contents($file_path)); |
|
80 | 80 | $new_contents = ($after) ? str_replace($insert_marker, $insert_marker.$text, $contents) : str_replace($insert_marker, $text.$insert_marker, $contents); |
81 | 81 | $this->fileSystem->dumpFile($file_path, $new_contents); |
82 | 82 | } |
@@ -39,8 +39,9 @@ |
||
39 | 39 | { |
40 | 40 | $dir = base_path($path); |
41 | 41 | |
42 | - if (!is_dir($dir)) |
|
43 | - $this->fileSystem->mkdir($dir, 0755); |
|
42 | + if (!is_dir($dir)) { |
|
43 | + $this->fileSystem->mkdir($dir, 0755); |
|
44 | + } |
|
44 | 45 | |
45 | 46 | return $dir; |
46 | 47 | } |
@@ -5,19 +5,19 @@ |
||
5 | 5 | |
6 | 6 | class FileSystem extends SymphonyFilesystem |
7 | 7 | { |
8 | - public function clone($src, $dest){ |
|
9 | - $src = $this->getFullSourcePath($src); |
|
8 | + public function clone($src, $dest){ |
|
9 | + $src = $this->getFullSourcePath($src); |
|
10 | 10 | |
11 | - $dest = base_path($dest); |
|
11 | + $dest = base_path($dest); |
|
12 | 12 | |
13 | - if (is_dir($src)) { |
|
14 | - $this->mirror($src, $dest."/".basename($src)); |
|
15 | - }else{ |
|
16 | - $this->copy($src, $dest); |
|
17 | - } |
|
18 | - } |
|
13 | + if (is_dir($src)) { |
|
14 | + $this->mirror($src, $dest."/".basename($src)); |
|
15 | + }else{ |
|
16 | + $this->copy($src, $dest); |
|
17 | + } |
|
18 | + } |
|
19 | 19 | |
20 | - public function getFullSourcePath($path){ |
|
21 | - return realpath(__DIR__ . "/../resources/" . $path); |
|
22 | - } |
|
20 | + public function getFullSourcePath($path){ |
|
21 | + return realpath(__DIR__ . "/../resources/" . $path); |
|
22 | + } |
|
23 | 23 | } |
@@ -12,12 +12,12 @@ |
||
12 | 12 | |
13 | 13 | if (is_dir($src)) { |
14 | 14 | $this->mirror($src, $dest."/".basename($src)); |
15 | - }else{ |
|
15 | + } else { |
|
16 | 16 | $this->copy($src, $dest); |
17 | 17 | } |
18 | 18 | } |
19 | 19 | |
20 | - public function getFullSourcePath($path){ |
|
21 | - return realpath(__DIR__ . "/../resources/" . $path); |
|
20 | + public function getFullSourcePath($path) { |
|
21 | + return realpath(__DIR__."/../resources/".$path); |
|
22 | 22 | } |
23 | 23 | } |
@@ -12,7 +12,7 @@ |
||
12 | 12 | |
13 | 13 | if (is_dir($src)) { |
14 | 14 | $this->mirror($src, $dest."/".basename($src)); |
15 | - }else{ |
|
15 | + } else{ |
|
16 | 16 | $this->copy($src, $dest); |
17 | 17 | } |
18 | 18 | } |
@@ -38,8 +38,8 @@ discard block |
||
38 | 38 | $this->insertIntoFile( |
39 | 39 | $webRouteFile, |
40 | 40 | "<?php\n", |
41 | - "use App\\Http\\Controllers\\".$this->module->getModelName()."Controller;\n" |
|
42 | - ); |
|
41 | + "use App\\Http\\Controllers\\".$this->module->getModelName()."Controller;\n" |
|
42 | + ); |
|
43 | 43 | |
44 | 44 | $this->insertIntoFile( |
45 | 45 | $webRouteFile, |
@@ -47,13 +47,13 @@ discard block |
||
47 | 47 | "\n".$this->getTabs(1)."Route::resource('".$this->module->getModuleName()."', ".$this->module->getModelName()."Controller::class);" |
48 | 48 | ); |
49 | 49 | |
50 | - $generatedFiles[] = $webRouteFile; |
|
50 | + $generatedFiles[] = $webRouteFile; |
|
51 | 51 | |
52 | 52 | $this->insertIntoFile( |
53 | 53 | $backendWebRouteFile, |
54 | 54 | "<?php\n", |
55 | - "use App\\Http\\Controllers\\Backend\\".$this->module->getModelName()."Controller;\n" |
|
56 | - ); |
|
55 | + "use App\\Http\\Controllers\\Backend\\".$this->module->getModelName()."Controller;\n" |
|
56 | + ); |
|
57 | 57 | |
58 | 58 | $this->insertIntoFile( |
59 | 59 | $backendWebRouteFile, |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | $webRouteFile = $this->getPath("routes/frontend/")."web.php"; |
18 | 18 | $backendWebRouteFile = $this->getPath("routes/backend/")."web.php"; |
19 | 19 | |
20 | - if(self::$initializeFlag++ == 0){ |
|
20 | + if (self::$initializeFlag++ == 0) { |
|
21 | 21 | $this->initializeFiles([ |
22 | 22 | $webRouteFile => "Route", |
23 | 23 | $backendAuthRouteFile => "backend/routes/auth", |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | |
44 | 44 | $this->insertIntoFile( |
45 | 45 | $webRouteFile, |
46 | - "/" . "* Insert your routes here */", |
|
46 | + "/"."* Insert your routes here */", |
|
47 | 47 | "\n".$this->getTabs(1)."Route::resource('".$this->module->getModuleName()."', ".$this->module->getModelName()."Controller::class);" |
48 | 48 | ); |
49 | 49 | |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | |
58 | 58 | $this->insertIntoFile( |
59 | 59 | $backendWebRouteFile, |
60 | - "/" . "* Insert your routes here */", |
|
60 | + "/"."* Insert your routes here */", |
|
61 | 61 | "\n".$this->getTabs(1)."Route::resource('".$this->module->getModuleName()."', ".$this->module->getModelName()."Controller::class);" |
62 | 62 | ); |
63 | 63 |
@@ -1,22 +1,22 @@ |
||
1 | 1 | <?php |
2 | 2 | return [ |
3 | - 'items_to_generate' => [ |
|
4 | - 'Common' => [ |
|
5 | - 'Migration', |
|
6 | - 'Model', |
|
7 | - 'Seeder', |
|
8 | - 'Route' |
|
9 | - ], |
|
10 | - 'Frontend' => [ |
|
11 | - 'Controller', |
|
12 | - 'View' |
|
13 | - ], |
|
14 | - 'Backend' => [ |
|
15 | - 'Controller', |
|
16 | - 'Request', |
|
17 | - 'View' |
|
18 | - ] |
|
19 | - ], |
|
20 | - 'skip_generators' => [], |
|
21 | - 'override' => true |
|
3 | + 'items_to_generate' => [ |
|
4 | + 'Common' => [ |
|
5 | + 'Migration', |
|
6 | + 'Model', |
|
7 | + 'Seeder', |
|
8 | + 'Route' |
|
9 | + ], |
|
10 | + 'Frontend' => [ |
|
11 | + 'Controller', |
|
12 | + 'View' |
|
13 | + ], |
|
14 | + 'Backend' => [ |
|
15 | + 'Controller', |
|
16 | + 'Request', |
|
17 | + 'View' |
|
18 | + ] |
|
19 | + ], |
|
20 | + 'skip_generators' => [], |
|
21 | + 'override' => true |
|
22 | 22 | ]; |
23 | 23 | \ No newline at end of file |
@@ -26,8 +26,8 @@ discard block |
||
26 | 26 | |
27 | 27 | $valid = $this->validateUpload($file, $moduleName, $field); |
28 | 28 | |
29 | - if($valid){ |
|
30 | - $imagename = $this->getWritableFilename(str_slug(pathinfo($file->getClientOriginalName(), PATHINFO_FILENAME)).'.'.$file->getClientOriginalExtension(), $moduleName, true);; |
|
29 | + if ($valid) { |
|
30 | + $imagename = $this->getWritableFilename(str_slug(pathinfo($file->getClientOriginalName(), PATHINFO_FILENAME)).'.'.$file->getClientOriginalExtension(), $moduleName, true); ; |
|
31 | 31 | |
32 | 32 | $destinationPath = storage_path('images/'.$moduleName); |
33 | 33 | |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | $files = []; |
47 | 47 | |
48 | 48 | foreach ($request->file('file') as $file) { |
49 | - $imagename = $this->getWritableFilename(str_slug(pathinfo($file->getClientOriginalName(), PATHINFO_FILENAME)).'.'.$file->getClientOriginalExtension(), $moduleName, true);; |
|
49 | + $imagename = $this->getWritableFilename(str_slug(pathinfo($file->getClientOriginalName(), PATHINFO_FILENAME)).'.'.$file->getClientOriginalExtension(), $moduleName, true); ; |
|
50 | 50 | $destinationPath = storage_path('images/'.$moduleName); |
51 | 51 | try { |
52 | 52 | $file->move($destinationPath, $imagename); |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | } |
57 | 57 | } |
58 | 58 | |
59 | - if(!isset($error)){ |
|
59 | + if (!isset($error)) { |
|
60 | 60 | return response()->json(['message' => 'File successfully uploaded', 'filenames' => $files, 'status' => 200], 200); |
61 | 61 | } |
62 | 62 | |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | public function delete(Request $request) |
67 | 67 | { |
68 | 68 | $moduleName = $request->input('modelName'); |
69 | - $modelToCall = "App\\Models\\" . ucfirst($moduleName); |
|
69 | + $modelToCall = "App\\Models\\".ucfirst($moduleName); |
|
70 | 70 | $model = $modelToCall::find($request->input('modelId')); |
71 | 71 | $field = $request->input('field'); |
72 | 72 | $filename = $model->$field; |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | */ |
90 | 90 | public function process($filename, $moduleName) |
91 | 91 | { |
92 | - $messages=['errors'=>[]]; |
|
92 | + $messages = ['errors'=>[]]; |
|
93 | 93 | $tempFile = storage_path('images/'.$moduleName.'/'.$filename); |
94 | 94 | $fileToWrite = $this->getWritableFilename($filename, $moduleName); |
95 | 95 | |
@@ -98,25 +98,25 @@ discard block |
||
98 | 98 | $methodToUse = $tempImage->width() > $tempImage->height() ? 'widen' : 'heighten'; |
99 | 99 | |
100 | 100 | try { |
101 | - $tempImage->$methodToUse(2000, function ($constraint){ |
|
101 | + $tempImage->$methodToUse(2000, function($constraint) { |
|
102 | 102 | $constraint->upsize(); |
103 | 103 | })->save($fileToWrite); |
104 | 104 | $messages['success']['filename'] = $fileToWrite; |
105 | 105 | } catch (\Exception $ex) { |
106 | - $messages['errors'][] = [ 'fileError' => $ex->getMessage()]; |
|
106 | + $messages['errors'][] = ['fileError' => $ex->getMessage()]; |
|
107 | 107 | } |
108 | 108 | return $messages; |
109 | 109 | } |
110 | 110 | |
111 | - protected function getWritableFilename($filename, $moduleName, $is_storage=false) |
|
111 | + protected function getWritableFilename($filename, $moduleName, $is_storage = false) |
|
112 | 112 | { |
113 | 113 | $dir = $is_storage ? $this->getPath(storage_path('images/'.$moduleName)) : $this->getPath(public_path('images/'.$moduleName)); |
114 | 114 | $path = $dir.'/'.$filename; |
115 | 115 | if (file_exists($path)) { |
116 | 116 | $filename = pathinfo($path, PATHINFO_FILENAME); |
117 | - $filename .= rand(0,9).'.'.pathinfo($path, PATHINFO_EXTENSION); |
|
117 | + $filename .= rand(0, 9).'.'.pathinfo($path, PATHINFO_EXTENSION); |
|
118 | 118 | return $this->getWritableFilename($filename, $moduleName, $is_storage); |
119 | - }else{ |
|
119 | + } else { |
|
120 | 120 | return $is_storage ? $filename : $path; |
121 | 121 | } |
122 | 122 | } |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | |
138 | 138 | $file = array($field => $file); |
139 | 139 | |
140 | - $validator = Validator::make($file , [ |
|
140 | + $validator = Validator::make($file, [ |
|
141 | 141 | $field => $rules, |
142 | 142 | ]); |
143 | 143 |
@@ -116,15 +116,16 @@ |
||
116 | 116 | $filename = pathinfo($path, PATHINFO_FILENAME); |
117 | 117 | $filename .= rand(0,9).'.'.pathinfo($path, PATHINFO_EXTENSION); |
118 | 118 | return $this->getWritableFilename($filename, $moduleName, $is_storage); |
119 | - }else{ |
|
119 | + } else{ |
|
120 | 120 | return $is_storage ? $filename : $path; |
121 | 121 | } |
122 | 122 | } |
123 | 123 | |
124 | 124 | protected function getPath($path) |
125 | 125 | { |
126 | - if (!is_dir($path)) |
|
127 | - mkdir($path, 0755, true); |
|
126 | + if (!is_dir($path)) { |
|
127 | + mkdir($path, 0755, true); |
|
128 | + } |
|
128 | 129 | |
129 | 130 | return $path; |
130 | 131 | } |
@@ -1,5 +1,5 @@ |
||
1 | 1 | <?php |
2 | - /** |
|
2 | + /** |
|
3 | 3 | * Helper Functions for Lagaren |
4 | 4 | * Autoloads via LaragenServiceProvider |
5 | 5 | */ |
@@ -36,10 +36,10 @@ |
||
36 | 36 | public function register() |
37 | 37 | { |
38 | 38 | // Register Intervention Provider and Facade |
39 | - $this->app->register(ImageServiceProvider::class); |
|
39 | + $this->app->register(ImageServiceProvider::class); |
|
40 | 40 | AliasLoader::getInstance()->alias('Image', Image::class); |
41 | 41 | |
42 | - $this->app->register("\App\Providers\LaragenRouteServiceProvider"); |
|
42 | + $this->app->register("\App\Providers\LaragenRouteServiceProvider"); |
|
43 | 43 | |
44 | 44 | $this->app->bind('command.laragen:make', Generate::class); |
45 | 45 |
@@ -12,23 +12,23 @@ |
||
12 | 12 | |
13 | 13 | $generatedFiles = []; |
14 | 14 | foreach ($viewsToBeGenerated as $view) { |
15 | - $viewTemplate = $this->buildTemplate('frontend/views/' . $view, [ |
|
15 | + $viewTemplate = $this->buildTemplate('frontend/views/'.$view, [ |
|
16 | 16 | '{{modelNameSingularLowercase}}' => $this->module->getModelNameLowercase(), |
17 | 17 | '{{modelNamePlural}}' => $this->module->getModelNamePlural(), |
18 | 18 | '{{moduleName}}' => $this->module->getModuleName() |
19 | 19 | ]); |
20 | 20 | |
21 | - $fullFilePath = $this->getPath("resources/views/" . $this->module->getModuleName()) . "/{$view}.blade.php"; |
|
21 | + $fullFilePath = $this->getPath("resources/views/".$this->module->getModuleName())."/{$view}.blade.php"; |
|
22 | 22 | file_put_contents($fullFilePath, $viewTemplate); |
23 | - $generatedFiles[] = $fullFilePath; |
|
23 | + $generatedFiles[] = $fullFilePath; |
|
24 | 24 | } |
25 | 25 | |
26 | - $layoutPath = $this->getPath("resources/views/laragen/layouts/") . "app.blade.php"; |
|
27 | - if(!file_exists($layoutPath)){ |
|
26 | + $layoutPath = $this->getPath("resources/views/laragen/layouts/")."app.blade.php"; |
|
27 | + if (!file_exists($layoutPath)) { |
|
28 | 28 | |
29 | 29 | $viewTemplate = $this->buildTemplate('frontend/views/layouts/app', []); |
30 | 30 | file_put_contents($layoutPath, $viewTemplate); |
31 | - $generatedFiles[] = $layoutPath; |
|
31 | + $generatedFiles[] = $layoutPath; |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | return $generatedFiles; |