@@ -19,7 +19,7 @@ |
||
19 | 19 | if (!count($indexFields)) { |
20 | 20 | throw new Exception("You must provide at least one field to an index"); |
21 | 21 | } |
22 | - $generator->createCode[] = '$table->index(["' . implode('", "', $indexFields) .'"]);'; |
|
22 | + $generator->createCode[] = '$table->index(["' . implode('", "', $indexFields) . '"]);'; |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | public static function processMigrationFieldDirective( |
@@ -56,7 +56,7 @@ |
||
56 | 56 | if (!count($indexFields)) { |
57 | 57 | throw new Exception("You must provide at least one field to an index on a model"); |
58 | 58 | } |
59 | - $generator->createCode[] = '$table->unique(["' . implode('", "', $indexFields) .'"]);'; |
|
59 | + $generator->createCode[] = '$table->unique(["' . implode('", "', $indexFields) . '"]);'; |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | public static function processMigrationFieldDirective( |
@@ -41,9 +41,9 @@ |
||
41 | 41 | $name = $directive->name->value; |
42 | 42 | |
43 | 43 | switch ($name) { |
44 | - case 'belongToMany': |
|
45 | - case 'morphedByMany': |
|
46 | - throw new DirectiveException("Foreign keys cannot be used with many-to-many-relationships. Check field: " . $field->name); |
|
44 | + case 'belongToMany': |
|
45 | + case 'morphedByMany': |
|
46 | + throw new DirectiveException("Foreign keys cannot be used with many-to-many-relationships. Check field: " . $field->name); |
|
47 | 47 | } |
48 | 48 | } |
49 | 49 |
@@ -24,7 +24,7 @@ |
||
24 | 24 | } |
25 | 25 | $generator->postCreateCode[] = |
26 | 26 | "if (!App::environment('testing')) { |
27 | - DB::statement('ALTER TABLE " . $generator->getTableName() . |
|
27 | + DB::statement('ALTER TABLE " . $generator->getTableName() . |
|
28 | 28 | " ADD FULLTEXT fulltext_index (`" . implode('`, `', $indexFields) . "`)'); |
29 | 29 | }"; |
30 | 30 | } |
@@ -156,11 +156,11 @@ discard block |
||
156 | 156 | $writtenFiles = $this->writeFiles( |
157 | 157 | $collection, |
158 | 158 | $basepath, |
159 | - function (GeneratedItem $i) use ($match) { |
|
160 | - if ((bool)$this->option('overwrite') === true) { |
|
159 | + function(GeneratedItem $i) use ($match) { |
|
160 | + if ((bool) $this->option('overwrite') === true) { |
|
161 | 161 | return true; |
162 | 162 | } |
163 | - if ((bool)$this->option('overwrite-graphql') === true) { |
|
163 | + if ((bool) $this->option('overwrite-graphql') === true) { |
|
164 | 164 | if ( |
165 | 165 | StringUtil::endsWith($i->filename, '.graphql') |
166 | 166 | ) { |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | // this runs all prettier commands in parallel. |
190 | 190 | $run = array_reduce( |
191 | 191 | $writtenFiles, |
192 | - function ($carry, $f) use ($command) { |
|
192 | + function($carry, $f) use ($command) { |
|
193 | 193 | return $carry . '(' . $command . $f . ') & '; |
194 | 194 | } |
195 | 195 | ); |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | // this runs all prettier commands in parallel. |
209 | 209 | $run = array_reduce( |
210 | 210 | $writtenFiles, |
211 | - function ($carry, $f) use ($command) { |
|
211 | + function($carry, $f) use ($command) { |
|
212 | 212 | return $carry . '(' . $command . $f . ') & '; |
213 | 213 | } |
214 | 214 | ); |
@@ -34,24 +34,24 @@ |
||
34 | 34 | |
35 | 35 | foreach ($directive->arguments as $arg) { |
36 | 36 | switch ($arg->name->value) { |
37 | - case 'ability': |
|
38 | - // @phpstan-ignore-next-line |
|
39 | - $ability = $arg->value->value; |
|
40 | - break; |
|
41 | - case 'find': |
|
42 | - // @phpstan-ignore-next-line |
|
43 | - $find = $arg->value->value; |
|
44 | - break; |
|
45 | - case 'model': |
|
46 | - // @phpstan-ignore-next-line |
|
47 | - $modelName = $arg->value->value; |
|
48 | - break; |
|
49 | - case 'injectArgs': |
|
50 | - $injected = true; |
|
51 | - break; |
|
52 | - case 'args': |
|
53 | - $args = true; |
|
54 | - break; |
|
37 | + case 'ability': |
|
38 | + // @phpstan-ignore-next-line |
|
39 | + $ability = $arg->value->value; |
|
40 | + break; |
|
41 | + case 'find': |
|
42 | + // @phpstan-ignore-next-line |
|
43 | + $find = $arg->value->value; |
|
44 | + break; |
|
45 | + case 'model': |
|
46 | + // @phpstan-ignore-next-line |
|
47 | + $modelName = $arg->value->value; |
|
48 | + break; |
|
49 | + case 'injectArgs': |
|
50 | + $injected = true; |
|
51 | + break; |
|
52 | + case 'args': |
|
53 | + $args = true; |
|
54 | + break; |
|
55 | 55 | } |
56 | 56 | } |
57 | 57 |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | Button::TYPE => ($hasVueRouter ? 'router-link' : 'a'), |
129 | 129 | Button::ATTRIBUTES => [ |
130 | 130 | $targetAttribute => "/{$routeBase}/edit", |
131 | - ] + ($hasCan ? [ "v-if" => 'can(\'create\')' ]: []), |
|
131 | + ] + ($hasCan ? ["v-if" => 'can(\'create\')'] : []), |
|
132 | 132 | ] |
133 | 133 | )->setContent( |
134 | 134 | '<i class="fa fa-plus"></i> Add new', |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | Button::TYPE => ($hasVueRouter ? 'router-link' : 'a'), |
143 | 143 | Button::ATTRIBUTES => [ |
144 | 144 | $targetAttribute => "'/{$routeBase}/' + model.{$keyAttribute} + '/edit'", |
145 | - ] + ($hasCan ? [ "v-if" => 'can(\'edit\')' ]: []), |
|
145 | + ] + ($hasCan ? ["v-if" => 'can(\'edit\')'] : []), |
|
146 | 146 | ] |
147 | 147 | )->setContent( |
148 | 148 | '<i class="fa fa-pencil"></i> Edit', |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | Button::ATTRIBUTES => [ |
159 | 159 | 'href' => '#', |
160 | 160 | '@click.prevent' => 'remove', |
161 | - ] + ($hasCan ? [ "v-if" => 'can(\'delete\')' ]: []), |
|
161 | + ] + ($hasCan ? ["v-if" => 'can(\'delete\')'] : []), |
|
162 | 162 | ] |
163 | 163 | )->setContent( |
164 | 164 | '<i class="fa fa-trash"></i> Delete', |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | $this->generator->templateParameters['options'] = $this->options->getSection('vue'); |
179 | 179 | |
180 | 180 | $this->generator->templateParameters['tableItemFields'] = |
181 | - array_values(array_map(function (Field $f) { |
|
181 | + array_values(array_map(function(Field $f) { |
|
182 | 182 | if ($f->getDatatype()->getBasetype() === 'relationship') { |
183 | 183 | $name = $f->getName(); |
184 | 184 | return "<{$name}-link v-bind=\"{$name}\"></{$name}-link>"; |
@@ -273,7 +273,7 @@ discard block |
||
273 | 273 | 'required' => true |
274 | 274 | ] |
275 | 275 | ]; |
276 | - $cardFieldNames = array_map(function (Field $f) { |
|
276 | + $cardFieldNames = array_map(function(Field $f) { |
|
277 | 277 | return $f->getName(); |
278 | 278 | }, $this->generator->getCardFields()); |
279 | 279 | $vueCode->setExtraProps($extraprops); |
@@ -299,7 +299,7 @@ discard block |
||
299 | 299 | $vueCode = $vue->getVueCode(); |
300 | 300 | // set basic data for vue |
301 | 301 | $vueCode->setExtraProps([]); |
302 | - $cardFieldNames = array_map(function (Field $f) { |
|
302 | + $cardFieldNames = array_map(function(Field $f) { |
|
303 | 303 | return $f->getName(); |
304 | 304 | }, $this->generator->getCardFields()); |
305 | 305 | foreach ($this->generator->getCardFields() as $f) { |
@@ -324,7 +324,7 @@ discard block |
||
324 | 324 | public function vueTableItem(FrameworkVue $vue): void |
325 | 325 | { |
326 | 326 | $vueCode = $vue->getVueCode(); |
327 | - $tableFieldNames = array_map(function (Field $f) { |
|
327 | + $tableFieldNames = array_map(function(Field $f) { |
|
328 | 328 | return $f->getName(); |
329 | 329 | }, $this->generator->getTableFields()); |
330 | 330 | $extraprops = [ |
@@ -356,7 +356,7 @@ discard block |
||
356 | 356 | $vue, |
357 | 357 | 'Form', |
358 | 358 | 'editable', |
359 | - function (Field $f) { |
|
359 | + function(Field $f) { |
|
360 | 360 | if (!$f->getExtradata('modelFillable')) { |
361 | 361 | return false; |
362 | 362 | } |
@@ -381,7 +381,7 @@ discard block |
||
381 | 381 | |
382 | 382 | if ($mode == 'editable') { |
383 | 383 | $vue->setEditableTemplate( |
384 | - function (FrameworkVue $vue, array $data, Model $m) use ($stub) { |
|
384 | + function(FrameworkVue $vue, array $data, Model $m) use ($stub) { |
|
385 | 385 | return $this->generator->templateCallback($stub, $vue, $data, $m); |
386 | 386 | } |
387 | 387 | ); |
@@ -395,7 +395,7 @@ discard block |
||
395 | 395 | ); |
396 | 396 | } else { |
397 | 397 | $vue->setViewableTemplate( |
398 | - function (FrameworkVue $vue, array $data, Model $m) use ($stub) { |
|
398 | + function(FrameworkVue $vue, array $data, Model $m) use ($stub) { |
|
399 | 399 | return $this->generator->templateCallback($stub, $vue, $data, $m); |
400 | 400 | } |
401 | 401 | ); |
@@ -417,7 +417,7 @@ discard block |
||
417 | 417 | $path = $this->generator->getModel()->getName() . '/index.js'; |
418 | 418 | $name = $this->generator->getStudlyName(); |
419 | 419 | |
420 | - $contents = function ($basepath, $element) use ($name) { |
|
420 | + $contents = function($basepath, $element) use ($name) { |
|
421 | 421 | $dir = $basepath . '/' . $name; |
422 | 422 | $import = []; |
423 | 423 | $export = []; |
@@ -47,7 +47,7 @@ |
||
47 | 47 | */ |
48 | 48 | public static function scalars(array $datatypes, string $ns): array |
49 | 49 | { |
50 | - $graphql = [ "# File automatically generated by Modelarium\n" ]; |
|
50 | + $graphql = ["# File automatically generated by Modelarium\n"]; |
|
51 | 51 | |
52 | 52 | foreach ($datatypes as $name) { |
53 | 53 | $typeName = Str::studly($name); |
@@ -142,17 +142,17 @@ discard block |
||
142 | 142 | public function buildTemplateParameters(): void |
143 | 143 | { |
144 | 144 | $this->titleFields = $this->fModel->filterField( |
145 | - function (Field $field) { |
|
145 | + function(Field $field) { |
|
146 | 146 | return $field->getRenderable('title', false); |
147 | 147 | } |
148 | 148 | ); |
149 | 149 | $this->cardFields = $this->fModel->filterField( |
150 | - function (Field $field) { |
|
150 | + function(Field $field) { |
|
151 | 151 | return $field->getRenderable('card', false); |
152 | 152 | } |
153 | 153 | ); |
154 | 154 | $this->tableFields = $this->fModel->filterField( |
155 | - function (Field $field) { |
|
155 | + function(Field $field) { |
|
156 | 156 | return $field->getRenderable('table', false); |
157 | 157 | } |
158 | 158 | ); |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | 'Table', |
209 | 209 | [ |
210 | 210 | Table::ROW_NAMES => array_map( |
211 | - function (Field $field) { |
|
211 | + function(Field $field) { |
|
212 | 212 | return $field->getRenderable(Renderable::LABEL, $field->getName()); |
213 | 213 | }, |
214 | 214 | $this->tableFields |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | $t->appendContent('<slot name="extraHeaders" :props="$props"></slot>', true); |
234 | 234 | } |
235 | 235 | $titleFields = $this->fModel->filterField( |
236 | - function (Field $field) { |
|
236 | + function(Field $field) { |
|
237 | 237 | return $field->getRenderable('title', false); |
238 | 238 | } |
239 | 239 | ); |
@@ -259,7 +259,7 @@ discard block |
||
259 | 259 | 'keyAttribute' => $this->keyAttribute, |
260 | 260 | 'spinner' => $spinner, |
261 | 261 | 'tablelist' => $table->getRenderHTML(), |
262 | - 'tableItemFields' => array_keys(array_map(function (Field $f) { |
|
262 | + 'tableItemFields' => array_keys(array_map(function(Field $f) { |
|
263 | 263 | return $f->getName(); |
264 | 264 | }, $this->tableFields)), |
265 | 265 | 'typeTitle' => $this->fModel->getRenderable('name', $this->studlyName), |
@@ -337,13 +337,13 @@ discard block |
||
337 | 337 | $filters[] = [ |
338 | 338 | 'name' => $arg->name, |
339 | 339 | 'type' => $typename, |
340 | - 'graphqlType' => $arg->name . ': ' . |
|
340 | + 'graphqlType' => $arg->name . ': ' . |
|
341 | 341 | ($isArray ? '[' : '') . |
342 | 342 | $typename . |
343 | 343 | $isInternalRequiredString . // TODO: phpstan complains, issue with graphqlphp ($isInternalRequired ? '!' : '') . |
344 | 344 | ($isArray ? ']' : '') . |
345 | 345 | ($isRequired ? '!' : ''), |
346 | - 'required' => (bool)$isRequired, |
|
346 | + 'required' => (bool) $isRequired, |
|
347 | 347 | 'requiredJSBoolean' => $isRequired ? 'true' : 'false' |
348 | 348 | ]; |
349 | 349 | } |
@@ -359,13 +359,13 @@ discard block |
||
359 | 359 | * card |
360 | 360 | */ |
361 | 361 | $cardFieldNames = array_map( |
362 | - function (Field $field) { |
|
362 | + function(Field $field) { |
|
363 | 363 | return $field->getName(); |
364 | 364 | }, |
365 | 365 | $this->cardFields |
366 | 366 | ); |
367 | 367 | $graphqlQuery = $this->fModel->mapFields( |
368 | - function (Field $f) use ($cardFieldNames) { |
|
368 | + function(Field $f) use ($cardFieldNames) { |
|
369 | 369 | if (in_array($f->getName(), $cardFieldNames)) { |
370 | 370 | // TODO: filter subfields in relationships |
371 | 371 | return $f->toGraphqlQuery(); |
@@ -381,7 +381,7 @@ discard block |
||
381 | 381 | $filtersQuery = ', ' . join( |
382 | 382 | ', ', |
383 | 383 | array_map( |
384 | - function ($item) { |
|
384 | + function($item) { |
|
385 | 385 | // TODO: still buggy, misses the internal ! in [Xyz!]! |
386 | 386 | return '$' . $item['graphqlType']; |
387 | 387 | }, |
@@ -391,7 +391,7 @@ discard block |
||
391 | 391 | $filtersParams = ', ' . join( |
392 | 392 | ', ', |
393 | 393 | array_map( |
394 | - function ($item) { |
|
394 | + function($item) { |
|
395 | 395 | return $item['name'] . ': $' . $item['name']; |
396 | 396 | }, |
397 | 397 | $filters |
@@ -430,14 +430,14 @@ discard block |
||
430 | 430 | * table |
431 | 431 | */ |
432 | 432 | $tableFieldNames = array_map( |
433 | - function (Field $field) { |
|
433 | + function(Field $field) { |
|
434 | 434 | return $field->getName(); |
435 | 435 | }, |
436 | 436 | $this->tableFields |
437 | 437 | ); |
438 | 438 | |
439 | 439 | $graphqlQuery = $this->fModel->mapFields( |
440 | - function (Field $f) use ($tableFieldNames) { |
|
440 | + function(Field $f) use ($tableFieldNames) { |
|
441 | 441 | if (in_array($f->getName(), $tableFieldNames)) { |
442 | 442 | // TODO: filter subfields in relationships |
443 | 443 | return $f->toGraphqlQuery(); |
@@ -477,7 +477,7 @@ discard block |
||
477 | 477 | * item |
478 | 478 | */ |
479 | 479 | $graphqlQuery = $this->fModel->mapFields( |
480 | - function (Field $f) { |
|
480 | + function(Field $f) { |
|
481 | 481 | return \Modelarium\Frontend\Util::fieldShow($f) ? $f->toGraphqlQuery() : null; |
482 | 482 | } |
483 | 483 | ); |