Conditions | 1 |
Paths | 1 |
Total Lines | 14 |
Code Lines | 9 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php declare(strict_types=1); |
||
17 | public static function processModelFieldDirective( |
||
18 | ModelGenerator $generator, |
||
19 | \GraphQL\Type\Definition\FieldDefinition $field, |
||
20 | \GraphQL\Language\AST\Node $directive |
||
21 | ): void { |
||
22 | $fieldName = $field->name; |
||
23 | $studlyName = $generator->getStudlyName(); |
||
24 | $generator->class->addMethod('from' . Str::studly($fieldName)) |
||
25 | ->setPublic() |
||
26 | ->setStatic() |
||
27 | ->setReturnType('\\App\\Models\\' . $studlyName) |
||
28 | ->addComment("Factory from the $fieldName unique index") |
||
29 | ->setBody("return {$studlyName}::firstWhere('$fieldName', \$value);") |
||
30 | ->addParameter('value'); |
||
31 | } |
||
40 |