@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | 'implements' => implode( |
| 23 | 23 | ', ', |
| 24 | 24 | array_map( |
| 25 | - function ($i) { |
|
| 25 | + function($i) { |
|
| 26 | 26 | return Str::studly($i) . 'DirectiveInterface'; |
| 27 | 27 | }, |
| 28 | 28 | $processors |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | // Script example.php |
| 63 | -$longopts = array( |
|
| 63 | +$longopts = array( |
|
| 64 | 64 | "name:", |
| 65 | 65 | "processors:" |
| 66 | 66 | ); |
@@ -60,18 +60,18 @@ |
||
| 60 | 60 | $targetSingle = mb_strtolower($generator->getInflector()->singularize($datatype->getTarget())); |
| 61 | 61 | $targetPlural = $datatype->getTargetTable(); |
| 62 | 62 | switch ($datatype->getRelationship()) { |
| 63 | - case RelationshipFactory::RELATIONSHIP_ONE_TO_ONE: |
|
| 64 | - case RelationshipFactory::MORPH_ONE_TO_ONE: |
|
| 65 | - $target = $targetSingle; |
|
| 66 | - break; |
|
| 67 | - case RelationshipFactory::RELATIONSHIP_ONE_TO_MANY: |
|
| 68 | - case RelationshipFactory::MORPH_ONE_TO_MANY: |
|
| 69 | - $target = $datatype->getIsInverse() ? $targetSingle : $targetPlural; |
|
| 70 | - break; |
|
| 71 | - case RelationshipFactory::RELATIONSHIP_MANY_TO_MANY: |
|
| 72 | - case RelationshipFactory::MORPH_MANY_TO_MANY: |
|
| 73 | - $target = $targetPlural; |
|
| 74 | - break; |
|
| 63 | + case RelationshipFactory::RELATIONSHIP_ONE_TO_ONE: |
|
| 64 | + case RelationshipFactory::MORPH_ONE_TO_ONE: |
|
| 65 | + $target = $targetSingle; |
|
| 66 | + break; |
|
| 67 | + case RelationshipFactory::RELATIONSHIP_ONE_TO_MANY: |
|
| 68 | + case RelationshipFactory::MORPH_ONE_TO_MANY: |
|
| 69 | + $target = $datatype->getIsInverse() ? $targetSingle : $targetPlural; |
|
| 70 | + break; |
|
| 71 | + case RelationshipFactory::RELATIONSHIP_MANY_TO_MANY: |
|
| 72 | + case RelationshipFactory::MORPH_MANY_TO_MANY: |
|
| 73 | + $target = $targetPlural; |
|
| 74 | + break; |
|
| 75 | 75 | } |
| 76 | 76 | } |
| 77 | 77 | $generator->with[] = $target; |
@@ -233,7 +233,7 @@ |
||
| 233 | 233 | $this->fModel->appendExtradata( |
| 234 | 234 | new Extradata( |
| 235 | 235 | 'hasCan', |
| 236 | - [ new ExtradataParameter('value', true) ] |
|
| 236 | + [new ExtradataParameter('value', true)] |
|
| 237 | 237 | ) |
| 238 | 238 | ); |
| 239 | 239 | return; |
@@ -23,7 +23,7 @@ |
||
| 23 | 23 | throw new Exception("You must provide at least one field to a full text index"); |
| 24 | 24 | } |
| 25 | 25 | $generator->postCreateCode[] = "DB::statement('ALTER TABLE " . |
| 26 | - $generator->getTableName() . |
|
| 26 | + $generator->getTableName() . |
|
| 27 | 27 | " ADD FULLTEXT fulltext_index (`" . |
| 28 | 28 | implode('`, `', $indexFields) . |
| 29 | 29 | "`)');"; |
@@ -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( |
@@ -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' ]; |
|
| 50 | + $graphql = ['# File automatically generated by Modelarium']; |
|
| 51 | 51 | |
| 52 | 52 | foreach ($datatypes as $name) { |
| 53 | 53 | $typeName = Str::studly($name); |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | Button::TYPE => ($hasVueRouter ? 'router-link' : 'a'), |
| 122 | 122 | Button::ATTRIBUTES => [ |
| 123 | 123 | $targetAttribute => "/{$routeBase}/edit", |
| 124 | - ] + ($hasCan ? [ "v-if" => 'can.create' ]: []), |
|
| 124 | + ] + ($hasCan ? ["v-if" => 'can.create'] : []), |
|
| 125 | 125 | ] |
| 126 | 126 | )->setContent( |
| 127 | 127 | '<i class="fa fa-plus"></i> Add new', |
@@ -135,7 +135,7 @@ discard block |
||
| 135 | 135 | Button::TYPE => ($hasVueRouter ? 'router-link' : 'a'), |
| 136 | 136 | Button::ATTRIBUTES => [ |
| 137 | 137 | $targetAttribute => "'/{$routeBase}/' + model.{$keyAttribute} + '/edit'", |
| 138 | - ] + ($hasCan ? [ "v-if" => 'can.edit' ]: []), |
|
| 138 | + ] + ($hasCan ? ["v-if" => 'can.edit'] : []), |
|
| 139 | 139 | ] |
| 140 | 140 | )->setContent( |
| 141 | 141 | '<i class="fa fa-pencil"></i> Edit', |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | Button::ATTRIBUTES => [ |
| 152 | 152 | 'href' => '#', |
| 153 | 153 | '@click.prevent' => 'remove', |
| 154 | - ] + ($hasCan ? [ "v-if" => 'can.delete' ]: []), |
|
| 154 | + ] + ($hasCan ? ["v-if" => 'can.delete'] : []), |
|
| 155 | 155 | ] |
| 156 | 156 | )->setContent( |
| 157 | 157 | '<i class="fa fa-trash"></i> Delete', |
@@ -171,7 +171,7 @@ discard block |
||
| 171 | 171 | $this->generator->templateParameters['options'] = $this->options->getSection('vue'); |
| 172 | 172 | |
| 173 | 173 | $this->generator->templateParameters['tableItemFields'] = |
| 174 | - array_values(array_map(function (Field $f) { |
|
| 174 | + array_values(array_map(function(Field $f) { |
|
| 175 | 175 | if ($f->getDatatype()->getBasetype() === 'relationship') { |
| 176 | 176 | $name = $f->getName(); |
| 177 | 177 | return "<{$name}-link v-bind=\"{$name}\"></{$name}-link>"; |
@@ -256,7 +256,7 @@ discard block |
||
| 256 | 256 | 'required' => true |
| 257 | 257 | ] |
| 258 | 258 | ]; |
| 259 | - $cardFieldNames = array_map(function (Field $f) { |
|
| 259 | + $cardFieldNames = array_map(function(Field $f) { |
|
| 260 | 260 | return $f->getName(); |
| 261 | 261 | }, $this->generator->getCardFields()); |
| 262 | 262 | $vueCode->setExtraProps($extraprops); |
@@ -289,7 +289,7 @@ discard block |
||
| 289 | 289 | ] |
| 290 | 290 | ]; |
| 291 | 291 | $vueCode->setExtraProps($extraprops); |
| 292 | - $cardFieldNames = array_map(function (Field $f) { |
|
| 292 | + $cardFieldNames = array_map(function(Field $f) { |
|
| 293 | 293 | return $f->getName(); |
| 294 | 294 | }, $this->generator->getCardFields()); |
| 295 | 295 | foreach ($this->generator->getCardFields() as $f) { |
@@ -314,7 +314,7 @@ discard block |
||
| 314 | 314 | public function vueTableItem(FrameworkVue $vue): void |
| 315 | 315 | { |
| 316 | 316 | $vueCode = $vue->getVueCode(); |
| 317 | - $tableFieldNames = array_map(function (Field $f) { |
|
| 317 | + $tableFieldNames = array_map(function(Field $f) { |
|
| 318 | 318 | return $f->getName(); |
| 319 | 319 | }, $this->generator->getTableFields()); |
| 320 | 320 | $extraprops = [ |
@@ -346,7 +346,7 @@ discard block |
||
| 346 | 346 | $vue, |
| 347 | 347 | 'Form', |
| 348 | 348 | 'editable', |
| 349 | - function (Field $f) { |
|
| 349 | + function(Field $f) { |
|
| 350 | 350 | if (!$f->getExtradata('modelFillable')) { |
| 351 | 351 | return false; |
| 352 | 352 | } |
@@ -371,7 +371,7 @@ discard block |
||
| 371 | 371 | |
| 372 | 372 | if ($mode == 'editable') { |
| 373 | 373 | $vue->setEditableTemplate( |
| 374 | - function (FrameworkVue $vue, array $data, Model $m) use ($stub) { |
|
| 374 | + function(FrameworkVue $vue, array $data, Model $m) use ($stub) { |
|
| 375 | 375 | return $this->generator->templateCallback($stub, $vue, $data, $m); |
| 376 | 376 | } |
| 377 | 377 | ); |
@@ -385,7 +385,7 @@ discard block |
||
| 385 | 385 | ); |
| 386 | 386 | } else { |
| 387 | 387 | $vue->setViewableTemplate( |
| 388 | - function (FrameworkVue $vue, array $data, Model $m) use ($stub) { |
|
| 388 | + function(FrameworkVue $vue, array $data, Model $m) use ($stub) { |
|
| 389 | 389 | return $this->generator->templateCallback($stub, $vue, $data, $m); |
| 390 | 390 | } |
| 391 | 391 | ); |
@@ -417,14 +417,14 @@ discard block |
||
| 417 | 417 | ]; |
| 418 | 418 | |
| 419 | 419 | $import = array_map( |
| 420 | - function ($i) use ($name) { |
|
| 420 | + function($i) use ($name) { |
|
| 421 | 421 | return "import {$name}$i from './{$name}$i.vue';"; |
| 422 | 422 | }, |
| 423 | 423 | $items |
| 424 | 424 | ); |
| 425 | 425 | |
| 426 | 426 | $export = array_map( |
| 427 | - function ($i) use ($name) { |
|
| 427 | + function($i) use ($name) { |
|
| 428 | 428 | return " {$name}$i,"; |
| 429 | 429 | }, |
| 430 | 430 | $items |
@@ -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 |
@@ -226,7 +226,7 @@ discard block |
||
| 226 | 226 | true |
| 227 | 227 | ); |
| 228 | 228 | $titleFields = $this->fModel->filterField( |
| 229 | - function (Field $field) { |
|
| 229 | + function(Field $field) { |
|
| 230 | 230 | return $field->getRenderable('title', false); |
| 231 | 231 | } |
| 232 | 232 | ); |
@@ -252,7 +252,7 @@ discard block |
||
| 252 | 252 | 'keyAttribute' => $this->keyAttribute, |
| 253 | 253 | 'spinner' => $spinner, |
| 254 | 254 | 'tablelist' => $table->getRenderHTML(), |
| 255 | - 'tableItemFields' => array_keys(array_map(function (Field $f) { |
|
| 255 | + 'tableItemFields' => array_keys(array_map(function(Field $f) { |
|
| 256 | 256 | return $f->getName(); |
| 257 | 257 | }, $this->tableFields)), |
| 258 | 258 | 'typeTitle' => $this->fModel->getRenderable('name', $this->studlyName), |
@@ -330,13 +330,13 @@ discard block |
||
| 330 | 330 | $filters[] = [ |
| 331 | 331 | 'name' => $arg->name, |
| 332 | 332 | 'type' => $typename, |
| 333 | - 'graphqlType' => $arg->name . ': ' . |
|
| 333 | + 'graphqlType' => $arg->name . ': ' . |
|
| 334 | 334 | ($isArray ? '[' : '') . |
| 335 | 335 | $typename . |
| 336 | 336 | $isInternalRequiredString, // TODO: phpstan complains, issue with graphqlphp ($isInternalRequired ? '!' : '') . |
| 337 | 337 | ($isArray ? ']' : '') . |
| 338 | 338 | ($isRequired ? '!' : ''), |
| 339 | - 'required' => (bool)$isRequired, |
|
| 339 | + 'required' => (bool) $isRequired, |
|
| 340 | 340 | 'requiredJSBoolean' => $isRequired ? 'true' : 'false' |
| 341 | 341 | ]; |
| 342 | 342 | } |
@@ -352,13 +352,13 @@ discard block |
||
| 352 | 352 | * card |
| 353 | 353 | */ |
| 354 | 354 | $cardFieldNames = array_map( |
| 355 | - function (Field $field) { |
|
| 355 | + function(Field $field) { |
|
| 356 | 356 | return $field->getName(); |
| 357 | 357 | }, |
| 358 | 358 | $this->cardFields |
| 359 | 359 | ); |
| 360 | 360 | $graphqlQuery = $this->fModel->mapFields( |
| 361 | - function (Field $f) use ($cardFieldNames) { |
|
| 361 | + function(Field $f) use ($cardFieldNames) { |
|
| 362 | 362 | if (in_array($f->getName(), $cardFieldNames)) { |
| 363 | 363 | // TODO: filter subfields in relationships |
| 364 | 364 | return $f->toGraphqlQuery(); |
@@ -374,7 +374,7 @@ discard block |
||
| 374 | 374 | $filtersQuery = ', ' . join( |
| 375 | 375 | ', ', |
| 376 | 376 | array_map( |
| 377 | - function ($item) { |
|
| 377 | + function($item) { |
|
| 378 | 378 | // TODO: still buggy, misses the internal ! in [Xyz!]! |
| 379 | 379 | return '$' . $item['graphqlType']; |
| 380 | 380 | }, |
@@ -384,7 +384,7 @@ discard block |
||
| 384 | 384 | $filtersParams = ', ' . join( |
| 385 | 385 | ', ', |
| 386 | 386 | array_map( |
| 387 | - function ($item) { |
|
| 387 | + function($item) { |
|
| 388 | 388 | return $item['name'] . ': $' . $item['name']; |
| 389 | 389 | }, |
| 390 | 390 | $filters |
@@ -423,14 +423,14 @@ discard block |
||
| 423 | 423 | * table |
| 424 | 424 | */ |
| 425 | 425 | $tableFieldNames = array_map( |
| 426 | - function (Field $field) { |
|
| 426 | + function(Field $field) { |
|
| 427 | 427 | return $field->getName(); |
| 428 | 428 | }, |
| 429 | 429 | $this->tableFields |
| 430 | 430 | ); |
| 431 | 431 | |
| 432 | 432 | $graphqlQuery = $this->fModel->mapFields( |
| 433 | - function (Field $f) use ($tableFieldNames) { |
|
| 433 | + function(Field $f) use ($tableFieldNames) { |
|
| 434 | 434 | if (in_array($f->getName(), $tableFieldNames)) { |
| 435 | 435 | // TODO: filter subfields in relationships |
| 436 | 436 | return $f->toGraphqlQuery(); |
@@ -470,7 +470,7 @@ discard block |
||
| 470 | 470 | * item |
| 471 | 471 | */ |
| 472 | 472 | $graphqlQuery = $this->fModel->mapFields( |
| 473 | - function (Field $f) { |
|
| 473 | + function(Field $f) { |
|
| 474 | 474 | return \Modelarium\Frontend\Util::fieldShow($f) ? $f->toGraphqlQuery() : null; |
| 475 | 475 | } |
| 476 | 476 | ); |