@@ -52,8 +52,7 @@ |
||
52 | 52 | { |
53 | 53 | try { |
54 | 54 | return $this->datatype->validate($value); |
55 | - } |
|
56 | - catch (ValidatorException $e) { |
|
55 | + } catch (ValidatorException $e) { |
|
57 | 56 | throw new Error($e->getMessage()); |
58 | 57 | } |
59 | 58 | } |
@@ -45,13 +45,13 @@ |
||
45 | 45 | |
46 | 46 | Event::listen( |
47 | 47 | RegisterDirectiveNamespaces::class, |
48 | - function (RegisterDirectiveNamespaces $registerDirectiveNamespaces): string { |
|
48 | + function(RegisterDirectiveNamespaces $registerDirectiveNamespaces): string { |
|
49 | 49 | return 'Modelarium\\Laravel\\Lighthouse\\Directives'; |
50 | 50 | } |
51 | 51 | ); |
52 | 52 | Event::listen( |
53 | 53 | RegisterDirectiveNamespaces::class, |
54 | - function (RegisterDirectiveNamespaces $registerDirectiveNamespaces): string { |
|
54 | + function(RegisterDirectiveNamespaces $registerDirectiveNamespaces): string { |
|
55 | 55 | return 'App\\Datatypes\\Types'; |
56 | 56 | } |
57 | 57 | ); |
@@ -43,7 +43,7 @@ |
||
43 | 43 | $previousResolver = $fieldValue->getResolver(); |
44 | 44 | |
45 | 45 | // Wrap around the resolver |
46 | - $wrappedResolver = function ($root, array $args, GraphQLContext $context, ResolveInfo $info) use ($previousResolver): string { |
|
46 | + $wrappedResolver = function($root, array $args, GraphQLContext $context, ResolveInfo $info) use ($previousResolver): string { |
|
47 | 47 | // Call the resolver, passing along the resolver arguments |
48 | 48 | /** @var string $result */ |
49 | 49 | $result = $previousResolver($root, $args, $context, $info); |
@@ -31,7 +31,7 @@ |
||
31 | 31 | /** |
32 | 32 | * @var string |
33 | 33 | */ |
34 | - protected $targetClass= ''; |
|
34 | + protected $targetClass = ''; |
|
35 | 35 | |
36 | 36 | /** |
37 | 37 | * If false, $source is "User" (class with HasOne/HasMany posts()) |
@@ -16,10 +16,10 @@ discard block |
||
16 | 16 | public const RELATIONSHIP = "RELATIONSHIP"; |
17 | 17 | public const RELATIONSHIP_ONE_TO_ONE = "11"; |
18 | 18 | public const RELATIONSHIP_ONE_TO_MANY = "1N"; |
19 | - public const RELATIONSHIP_MANY_TO_MANY = "NN"; |
|
19 | + public const RELATIONSHIP_MANY_TO_MANY = "NN"; |
|
20 | 20 | public const MORPH_ONE_TO_ONE = "M11"; |
21 | 21 | public const MORPH_ONE_TO_MANY = "M1N"; |
22 | - public const MORPH_MANY_TO_MANY = "MNN"; |
|
22 | + public const MORPH_MANY_TO_MANY = "MNN"; |
|
23 | 23 | |
24 | 24 | private function __construct() |
25 | 25 | { |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | if (!in_array($matches['mode'], $relationships)) { |
52 | 52 | throw new ClassNotFoundException('Invalid relationship'); |
53 | 53 | } |
54 | - return static::factory($matches['source'], $matches['target'], $matches['mode'], (bool)$matches['inverse']); |
|
54 | + return static::factory($matches['source'], $matches['target'], $matches['mode'], (bool) $matches['inverse']); |
|
55 | 55 | } |
56 | 56 | throw new ClassNotFoundException('Invalid relationship'); |
57 | 57 | } |
@@ -9,7 +9,7 @@ |
||
9 | 9 | function datatypes() |
10 | 10 | { |
11 | 11 | $markdown = DatatypeFactory::map( |
12 | - function (\ReflectionClass $reflection): array { |
|
12 | + function(\ReflectionClass $reflection): array { |
|
13 | 13 | $class = $reflection->getName(); |
14 | 14 | |
15 | 15 | /** |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | $files = $processor->getCollection(); |
92 | 92 | if ($name && $name !== '*' && $name !== 'all') { |
93 | 93 | $files = $files->filter( |
94 | - function (GeneratedItem $g) use ($name) { |
|
94 | + function(GeneratedItem $g) use ($name) { |
|
95 | 95 | if (is_array($name)) { |
96 | 96 | throw new \Exception('Arrays not supported yet'); |
97 | 97 | } else { |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | $this->writeFiles( |
105 | 105 | $files, |
106 | 106 | base_path(), |
107 | - (bool)$this->option('overwrite') |
|
107 | + (bool) $this->option('overwrite') |
|
108 | 108 | ); |
109 | 109 | $this->info('Finished scaffolding. You might want to run `composer dump-autoload`'); |
110 | 110 | } |
@@ -87,10 +87,10 @@ discard block |
||
87 | 87 | // $blade = FrameworkComposer::getByName('Blade'); |
88 | 88 | |
89 | 89 | if ($vue !== null) { |
90 | - $cardFieldNames = array_map(function (Field $f) { |
|
90 | + $cardFieldNames = array_map(function(Field $f) { |
|
91 | 91 | return $f->getName(); |
92 | 92 | }, $this->cardFields); |
93 | - $tableFieldNames = array_map(function (Field $f) { |
|
93 | + $tableFieldNames = array_map(function(Field $f) { |
|
94 | 94 | return $f->getName(); |
95 | 95 | }, $this->tableFields); |
96 | 96 | |
@@ -142,12 +142,12 @@ discard block |
||
142 | 142 | protected function buildTemplateParameters(): void |
143 | 143 | { |
144 | 144 | $this->cardFields = $this->model->filterField( |
145 | - function (Field $field) { |
|
145 | + function(Field $field) { |
|
146 | 146 | return $field->getRenderable('card', false); |
147 | 147 | } |
148 | 148 | ); |
149 | 149 | $this->tableFields = $this->model->filterField( |
150 | - function (Field $field) { |
|
150 | + function(Field $field) { |
|
151 | 151 | return $field->getRenderable('table', false); |
152 | 152 | } |
153 | 153 | ); |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | 'Button', |
160 | 160 | [ |
161 | 161 | Button::TYPE => 'a', |
162 | - Button::ATTRIBUTES => ['href' => "/{$this->lowerName}/edit" ], |
|
162 | + Button::ATTRIBUTES => ['href' => "/{$this->lowerName}/edit"], |
|
163 | 163 | ] |
164 | 164 | )->setContent( |
165 | 165 | '<i class="fa fa-plus"></i> Add new', |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | 'Table', |
203 | 203 | [ |
204 | 204 | Table::ROW_NAMES => array_map( |
205 | - function (Field $field) { |
|
205 | + function(Field $field) { |
|
206 | 206 | return $field->getRenderable(Renderable::LABEL, $field->getName()); |
207 | 207 | }, |
208 | 208 | $this->tableFields |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | true |
221 | 221 | ); |
222 | 222 | $titleFields = $this->model->filterField( |
223 | - function (Field $field) { |
|
223 | + function(Field $field) { |
|
224 | 224 | return $field->getRenderable('title', false); |
225 | 225 | } |
226 | 226 | ); |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | // TODO 'hasCan' => $this->model |
245 | 245 | 'spinner' => $spinner, |
246 | 246 | 'tablelist' => $table->getRenderHTML(), |
247 | - 'tableItemFields' => array_keys(array_map(function (Field $f) { |
|
247 | + 'tableItemFields' => array_keys(array_map(function(Field $f) { |
|
248 | 248 | return $f->getName(); |
249 | 249 | }, $this->tableFields)), |
250 | 250 | 'titleField' => array_key_first($titleFields) ?: 'id' |
@@ -272,7 +272,7 @@ discard block |
||
272 | 272 | |
273 | 273 | if ($mode == 'editable') { |
274 | 274 | $vue->setEditableTemplate( |
275 | - function (FrameworkVue $vue, array $data, Model $m) use ($stub) { |
|
275 | + function(FrameworkVue $vue, array $data, Model $m) use ($stub) { |
|
276 | 276 | return $this->templateCallback($stub, $vue, $data, $m); |
277 | 277 | } |
278 | 278 | ); |
@@ -286,7 +286,7 @@ discard block |
||
286 | 286 | ); |
287 | 287 | } else { |
288 | 288 | $vue->setViewableTemplate( |
289 | - function (FrameworkVue $vue, array $data, Model $m) use ($stub) { |
|
289 | + function(FrameworkVue $vue, array $data, Model $m) use ($stub) { |
|
290 | 290 | return $this->templateCallback($stub, $vue, $data, $m); |
291 | 291 | } |
292 | 292 | ); |
@@ -313,7 +313,7 @@ discard block |
||
313 | 313 | * card |
314 | 314 | */ |
315 | 315 | $cardFieldNames = array_map( |
316 | - function (Field $field) { |
|
316 | + function(Field $field) { |
|
317 | 317 | return $field->getName(); |
318 | 318 | }, |
319 | 319 | $this->cardFields |
@@ -349,7 +349,7 @@ discard block |
||
349 | 349 | * table |
350 | 350 | */ |
351 | 351 | $tableFieldNames = array_map( |
352 | - function (Field $field) { |
|
352 | + function(Field $field) { |
|
353 | 353 | return $field->getName(); |
354 | 354 | }, |
355 | 355 | $this->tableFields |
@@ -384,7 +384,7 @@ discard block |
||
384 | 384 | /* |
385 | 385 | * item |
386 | 386 | */ |
387 | - $graphqlQuery = $this->model->toGraphqlQuery();// TODO: filter !fillable, hidden |
|
387 | + $graphqlQuery = $this->model->toGraphqlQuery(); // TODO: filter !fillable, hidden |
|
388 | 388 | $itemQuery = <<<EOF |
389 | 389 | query (\$id: ID!) { |
390 | 390 | {$this->lowerName}(id: \$id) { |
@@ -447,14 +447,14 @@ discard block |
||
447 | 447 | ]; |
448 | 448 | |
449 | 449 | $import = array_map( |
450 | - function ($i) use ($name) { |
|
450 | + function($i) use ($name) { |
|
451 | 451 | return "import {$name}$i from './{$name}$i.vue';"; |
452 | 452 | }, |
453 | 453 | $items |
454 | 454 | ); |
455 | 455 | |
456 | 456 | $export = array_map( |
457 | - function ($i) use ($name) { |
|
457 | + function($i) use ($name) { |
|
458 | 458 | return " {$name}$i,\n"; |
459 | 459 | }, |
460 | 460 | $items |
@@ -54,17 +54,17 @@ |
||
54 | 54 | foreach ($directives as $directive) { |
55 | 55 | $name = $directive->name->value; |
56 | 56 | switch ($name) { |
57 | - case 'belongsToMany': |
|
58 | - $type1 = $this->lowerName; |
|
59 | - $type2 = $lowerName; |
|
60 | - if (strcasecmp($type1, $type2) < 0) { // TODO: check this, might not work |
|
61 | - $relationship = mb_strtolower($this->getInflector()->pluralize($field->name)); |
|
62 | - $this->extraCode[] = $this->makeManyToManySeed($type1, $type2, $relationship); |
|
63 | - } |
|
64 | - break; |
|
65 | - case 'morphedByMany': |
|
66 | - // TODO $relation = Parser::getDirectiveArgumentByName($directive, 'relation', $lowerName); |
|
67 | - break; |
|
57 | + case 'belongsToMany': |
|
58 | + $type1 = $this->lowerName; |
|
59 | + $type2 = $lowerName; |
|
60 | + if (strcasecmp($type1, $type2) < 0) { // TODO: check this, might not work |
|
61 | + $relationship = mb_strtolower($this->getInflector()->pluralize($field->name)); |
|
62 | + $this->extraCode[] = $this->makeManyToManySeed($type1, $type2, $relationship); |
|
63 | + } |
|
64 | + break; |
|
65 | + case 'morphedByMany': |
|
66 | + // TODO $relation = Parser::getDirectiveArgumentByName($directive, 'relation', $lowerName); |
|
67 | + break; |
|
68 | 68 | default: |
69 | 69 | break; |
70 | 70 | } |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | } |
39 | 39 | |
40 | 40 | return new GeneratedCollection( |
41 | - [ new GeneratedItem( |
|
41 | + [new GeneratedItem( |
|
42 | 42 | GeneratedItem::TYPE_SEED, |
43 | 43 | $this->generateString(), |
44 | 44 | $this->getGenerateFilename() |
@@ -101,6 +101,6 @@ discard block |
||
101 | 101 | |
102 | 102 | public function getGenerateFilename(): string |
103 | 103 | { |
104 | - return $this->getBasePath('database/seeds/'. $this->studlyName . 'Seeder.php'); |
|
104 | + return $this->getBasePath('database/seeds/' . $this->studlyName . 'Seeder.php'); |
|
105 | 105 | } |
106 | 106 | } |