Completed
Push — master ( 63d8d6...28be9d )
by Raphael
11:25
created
stubs/Api/Model/Model.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 	}
Please login to merge, or discard this patch.
stubs/Api/Migration.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -3,14 +3,14 @@
 block discarded – undo
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
 	}
Please login to merge, or discard this patch.
routes/generator.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -3,17 +3,17 @@  discard block
 block discarded – undo
3 3
 use Illuminate\Http\Request;
4 4
 use Illuminate\Support\Facades\File;
5 5
 
6
-Route::get('scaffolder/generator', function ()
6
+Route::get('scaffolder/generator', function()
7 7
 {
8 8
     return view('scaffolder::generator');
9 9
 });
10 10
 
11
-Route::post('scaffolder/add-model', function (Request $request)
11
+Route::post('scaffolder/add-model', function(Request $request)
12 12
 {
13 13
     return view('scaffolder::partials.model', ['modelId' => $request->input('modelId')]);
14 14
 });
15 15
 
16
-Route::post('scaffolder/add-field', function (Request $request)
16
+Route::post('scaffolder/add-field', function(Request $request)
17 17
 {
18 18
     return view('scaffolder::partials.field', [
19 19
         'modelId' => $request->input('modelId'),
@@ -21,11 +21,11 @@  discard block
 block discarded – undo
21 21
     ]);
22 22
 });
23 23
 
24
-Route::post('scaffolder/generate', function (Request $request)
24
+Route::post('scaffolder/generate', function(Request $request)
25 25
 {
26 26
     $models = $request->only('models');
27 27
 
28
-    array_walk_recursive($models, function (&$item)
28
+    array_walk_recursive($models, function(&$item)
29 29
     {
30 30
         if ($item == 'true') $item = true;
31 31
         elseif ($item == 'false') $item = false;
@@ -40,16 +40,16 @@  discard block
 block discarded – undo
40 40
     {
41 41
         $modelName = $model['modelName'];
42 42
         array_shift($model);
43
-        File::put(base_path('scaffolder-config/models/' . $modelName . '.json'),
43
+        File::put(base_path('scaffolder-config/models/'.$modelName.'.json'),
44 44
             json_encode($model, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
45 45
     }
46 46
 });
47 47
 
48
-Route::post('scaffolder/generate-and-execute', function (Request $request)
48
+Route::post('scaffolder/generate-and-execute', function(Request $request)
49 49
 {
50 50
     $models = $request->only('models');
51 51
 
52
-    array_walk_recursive($models, function (&$item)
52
+    array_walk_recursive($models, function(&$item)
53 53
     {
54 54
         if ($item == 'true') $item = true;
55 55
         elseif ($item == 'false') $item = false;
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
     {
65 65
         $modelName = $model['modelName'];
66 66
         array_shift($model);
67
-        File::put(base_path('scaffolder-config/models/' . $modelName . '.json'),
67
+        File::put(base_path('scaffolder-config/models/'.$modelName.'.json'),
68 68
             json_encode($model, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
69 69
     }
70 70
 
Please login to merge, or discard this patch.