@@ -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 | ); |
@@ -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); |
@@ -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 = (string)$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 = (string)$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 | |
@@ -36,7 +36,7 @@ |
||
| 36 | 36 | switch ($arg->name->value) { |
| 37 | 37 | case 'ability': |
| 38 | 38 | // @phpstan-ignore-next-line |
| 39 | - $ability = (string)$arg->value->value; |
|
| 39 | + $ability = (string) $arg->value->value; |
|
| 40 | 40 | break; |
| 41 | 41 | case 'find': |
| 42 | 42 | // @phpstan-ignore-next-line |
@@ -20,9 +20,9 @@ |
||
| 20 | 20 | $value = $arg->value->value; |
| 21 | 21 | |
| 22 | 22 | switch ($arg->name->value) { |
| 23 | - case 'class': |
|
| 24 | - $generator->parentClassName = (string)$value; |
|
| 25 | - break; |
|
| 23 | + case 'class': |
|
| 24 | + $generator->parentClassName = (string)$value; |
|
| 25 | + break; |
|
| 26 | 26 | } |
| 27 | 27 | } |
| 28 | 28 | } |
@@ -21,7 +21,7 @@ |
||
| 21 | 21 | |
| 22 | 22 | switch ($arg->name->value) { |
| 23 | 23 | case 'class': |
| 24 | - $generator->parentClassName = (string)$value; |
|
| 24 | + $generator->parentClassName = (string) $value; |
|
| 25 | 25 | break; |
| 26 | 26 | } |
| 27 | 27 | } |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | * @param string[] $directiveNamespaces |
| 79 | 79 | * @return array<string, string> |
| 80 | 80 | */ |
| 81 | - public static function getDirectivesGraphql($directiveNamespaces = [ 'Modelarium\Laravel\Lighthouse\Directives' ]): array |
|
| 81 | + public static function getDirectivesGraphql($directiveNamespaces = ['Modelarium\Laravel\Lighthouse\Directives']): array |
|
| 82 | 82 | { |
| 83 | 83 | $directives = []; |
| 84 | 84 | |
@@ -88,15 +88,15 @@ discard block |
||
| 88 | 88 | |
| 89 | 89 | foreach ($classesInNamespace as $class) { |
| 90 | 90 | $reflection = new \ReflectionClass($class); |
| 91 | - if (! $reflection->isInstantiable()) { |
|
| 91 | + if (!$reflection->isInstantiable()) { |
|
| 92 | 92 | continue; |
| 93 | 93 | } |
| 94 | 94 | |
| 95 | - if (! is_a($class, \Nuwave\Lighthouse\Schema\Directives\BaseDirective::class, true)) { |
|
| 95 | + if (!is_a($class, \Nuwave\Lighthouse\Schema\Directives\BaseDirective::class, true)) { |
|
| 96 | 96 | continue; |
| 97 | 97 | } |
| 98 | 98 | |
| 99 | - $name = \Nuwave\Lighthouse\Schema\DirectiveLocator::directiveName((string)$class); |
|
| 99 | + $name = \Nuwave\Lighthouse\Schema\DirectiveLocator::directiveName((string) $class); |
|
| 100 | 100 | $directives[$name] = trim($class::definition()); |
| 101 | 101 | } |
| 102 | 102 | } |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | * @param string[] $directiveNamespaces |
| 111 | 111 | * @return string |
| 112 | 112 | */ |
| 113 | - public static function getDirectivesGraphqlString($directiveNamespaces = [ 'Modelarium\\Laravel\\Lighthouse\\Directives' ]): string |
|
| 113 | + public static function getDirectivesGraphqlString($directiveNamespaces = ['Modelarium\\Laravel\\Lighthouse\\Directives']): string |
|
| 114 | 114 | { |
| 115 | 115 | return implode("\n\n", self::getDirectivesGraphql($directiveNamespaces)); |
| 116 | 116 | } |
@@ -167,7 +167,7 @@ discard block |
||
| 167 | 167 | if ($name === 'Query' || $name === 'Mutation' || $name === 'Subscription' || $name === 'Can') { |
| 168 | 168 | continue; |
| 169 | 169 | } |
| 170 | - $g = $this->processType((string)$name, $object); |
|
| 170 | + $g = $this->processType((string) $name, $object); |
|
| 171 | 171 | $this->collection = $this->collection->merge($g); |
| 172 | 172 | } |
| 173 | 173 | } |
@@ -178,7 +178,7 @@ discard block |
||
| 178 | 178 | { |
| 179 | 179 | $originalTypeLoader = $this->schema->getConfig()->typeLoader; |
| 180 | 180 | |
| 181 | - $this->schema->getConfig()->typeLoader = function ($typeName) use ($originalTypeLoader) { |
|
| 181 | + $this->schema->getConfig()->typeLoader = function($typeName) use ($originalTypeLoader) { |
|
| 182 | 182 | $type = $originalTypeLoader($typeName); |
| 183 | 183 | if ($type instanceof \GraphQL\Type\Definition\CustomScalarType) { |
| 184 | 184 | $scalarName = $type->name; |
@@ -193,7 +193,7 @@ discard block |
||
| 193 | 193 | { |
| 194 | 194 | $this->ast = Visitor::visit($this->ast, [ |
| 195 | 195 | // load the scalar type classes |
| 196 | - NodeKind::SCALAR_TYPE_DEFINITION => function ($node) { |
|
| 196 | + NodeKind::SCALAR_TYPE_DEFINITION => function($node) { |
|
| 197 | 197 | $scalarName = $node->name->value; |
| 198 | 198 | |
| 199 | 199 | if (in_array($scalarName, ['BuilderValue', 'CanArgs', 'EnumValue', 'EqValue'])) { |
@@ -211,7 +211,7 @@ discard block |
||
| 211 | 211 | |
| 212 | 212 | switch ($arg->name->value) { |
| 213 | 213 | case 'class': |
| 214 | - $className = (string)$value; |
|
| 214 | + $className = (string) $value; |
|
| 215 | 215 | break; |
| 216 | 216 | } |
| 217 | 217 | } |
@@ -257,7 +257,7 @@ discard block |
||
| 257 | 257 | return []; |
| 258 | 258 | } |
| 259 | 259 | return array_map( |
| 260 | - function ($i) use ($basedir) { |
|
| 260 | + function($i) use ($basedir) { |
|
| 261 | 261 | $name = $i[1]; |
| 262 | 262 | if (array_key_exists($name, $this->imports)) { |
| 263 | 263 | return $this->imports[$name]; |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | Button::TYPE => ($hasVueRouter ? 'router-link' : 'a'), |
| 100 | 100 | Button::ATTRIBUTES => [ |
| 101 | 101 | $targetAttribute => "/{$routeBase}/edit", |
| 102 | - ] + ($hasCan ? [ "v-if" => 'can(\'create\')' ]: []), |
|
| 102 | + ] + ($hasCan ? ["v-if" => 'can(\'create\')'] : []), |
|
| 103 | 103 | ] |
| 104 | 104 | )->setContent( |
| 105 | 105 | '<i class="fa fa-plus"></i> ' . $this->getOptions()->getOption('frontend', 'messages')['addNew'], |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | Button::TYPE => ($hasVueRouter ? 'router-link' : 'a'), |
| 114 | 114 | Button::ATTRIBUTES => [ |
| 115 | 115 | $targetAttribute => "'/{$routeBase}/' + model.{$keyAttribute} + '/edit'", |
| 116 | - ] + ($hasCan ? [ "v-if" => 'can(\'edit\')' ]: []), |
|
| 116 | + ] + ($hasCan ? ["v-if" => 'can(\'edit\')'] : []), |
|
| 117 | 117 | ] |
| 118 | 118 | )->setContent( |
| 119 | 119 | '<i class="fa fa-pencil"></i> ' . $this->getOptions()->getOption('frontend', 'messages')['edit'], |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | Button::ATTRIBUTES => [ |
| 130 | 130 | 'href' => '#', |
| 131 | 131 | '@click.prevent' => 'remove(model.id)', |
| 132 | - ] + ($hasCan ? [ "v-if" => 'can(\'delete\')' ]: []), |
|
| 132 | + ] + ($hasCan ? ["v-if" => 'can(\'delete\')'] : []), |
|
| 133 | 133 | ] |
| 134 | 134 | )->setContent( |
| 135 | 135 | '<i class="fa fa-trash"></i> ' . $this->getOptions()->getOption('frontend', 'messages')['delete'], |
@@ -149,7 +149,7 @@ discard block |
||
| 149 | 149 | $this->generator->templateParameters['options'] = $this->getOptions()->options; |
| 150 | 150 | |
| 151 | 151 | $this->generator->templateParameters['tableItemFields'] = |
| 152 | - array_values(array_map(function (Field $f) { |
|
| 152 | + array_values(array_map(function(Field $f) { |
|
| 153 | 153 | $required = $f->getValidator('required', false); |
| 154 | 154 | if ($f->getDatatype()->getBasetype() === 'relationship') { |
| 155 | 155 | $name = $f->getName(); |
@@ -245,7 +245,7 @@ discard block |
||
| 245 | 245 | 'required' => true |
| 246 | 246 | ] |
| 247 | 247 | ]; |
| 248 | - $cardFieldNames = array_map(function (Field $f) { |
|
| 248 | + $cardFieldNames = array_map(function(Field $f) { |
|
| 249 | 249 | return $f->getName(); |
| 250 | 250 | }, $this->generator->getCardFields()); |
| 251 | 251 | $vueCode->setExtraProps($extraprops); |
@@ -271,7 +271,7 @@ discard block |
||
| 271 | 271 | $vueCode = $vue->getVueCode(); |
| 272 | 272 | // set basic data for vue |
| 273 | 273 | $vueCode->setExtraProps([]); |
| 274 | - $cardFieldNames = array_map(function (Field $f) { |
|
| 274 | + $cardFieldNames = array_map(function(Field $f) { |
|
| 275 | 275 | return $f->getName(); |
| 276 | 276 | }, $this->generator->getCardFields()); |
| 277 | 277 | foreach ($this->generator->getCardFields() as $f) { |
@@ -304,7 +304,7 @@ discard block |
||
| 304 | 304 | public function vueTableItem(FrameworkVue $vue): void |
| 305 | 305 | { |
| 306 | 306 | $vueCode = $vue->getVueCode(); |
| 307 | - $tableFieldNames = array_map(function (Field $f) { |
|
| 307 | + $tableFieldNames = array_map(function(Field $f) { |
|
| 308 | 308 | return $f->getName(); |
| 309 | 309 | }, $this->generator->getTableFields()); |
| 310 | 310 | $vueCode->setExtraProps([]); |
@@ -351,7 +351,7 @@ discard block |
||
| 351 | 351 | $vueCode->setExtraProps([]); |
| 352 | 352 | |
| 353 | 353 | $createGraphqlVariables = $this->generator->getModel()->mapFields( |
| 354 | - function (Field $f) { |
|
| 354 | + function(Field $f) { |
|
| 355 | 355 | if (!$f->getRenderable('form', true)) { |
| 356 | 356 | return null; |
| 357 | 357 | } |
@@ -372,7 +372,7 @@ discard block |
||
| 372 | 372 | $vue, |
| 373 | 373 | 'Form', |
| 374 | 374 | 'editable', |
| 375 | - function (Field $f) { |
|
| 375 | + function(Field $f) { |
|
| 376 | 376 | if (!$f->getExtradata('modelFillable')) { |
| 377 | 377 | return false; |
| 378 | 378 | } |
@@ -397,7 +397,7 @@ discard block |
||
| 397 | 397 | |
| 398 | 398 | if ($mode == 'editable') { |
| 399 | 399 | $vue->setEditableTemplate( |
| 400 | - function (FrameworkVue $vue, array $data, Model $m) use ($stub) { |
|
| 400 | + function(FrameworkVue $vue, array $data, Model $m) use ($stub) { |
|
| 401 | 401 | return $this->generator->templateCallback($stub, $vue, $data, $m); |
| 402 | 402 | } |
| 403 | 403 | ); |
@@ -411,7 +411,7 @@ discard block |
||
| 411 | 411 | ); |
| 412 | 412 | } else { |
| 413 | 413 | $vue->setViewableTemplate( |
| 414 | - function (FrameworkVue $vue, array $data, Model $m) use ($stub) { |
|
| 414 | + function(FrameworkVue $vue, array $data, Model $m) use ($stub) { |
|
| 415 | 415 | return $this->generator->templateCallback($stub, $vue, $data, $m); |
| 416 | 416 | } |
| 417 | 417 | ); |
@@ -433,7 +433,7 @@ discard block |
||
| 433 | 433 | $path = $this->generator->getModel()->getName() . '/index.js'; |
| 434 | 434 | $name = $this->generator->getStudlyName(); |
| 435 | 435 | |
| 436 | - $contents = function ($basepath, $element) use ($name) { |
|
| 436 | + $contents = function($basepath, $element) use ($name) { |
|
| 437 | 437 | $dir = $basepath . '/' . $name; |
| 438 | 438 | $import = []; |
| 439 | 439 | $export = []; |
@@ -463,7 +463,7 @@ discard block |
||
| 463 | 463 | $path = $this->generator->getModel()->getName() . '/index.dynamic.js'; |
| 464 | 464 | $name = $this->generator->getStudlyName(); |
| 465 | 465 | |
| 466 | - $contents = function ($basepath, $element) use ($name) { |
|
| 466 | + $contents = function($basepath, $element) use ($name) { |
|
| 467 | 467 | $dir = $basepath . '/' . $name; |
| 468 | 468 | $import = []; |
| 469 | 469 | $export = []; |