1
|
|
|
<?php declare(strict_types=1); |
2
|
|
|
|
3
|
|
|
namespace Modelarium\Laravel\Directives; |
4
|
|
|
|
5
|
|
|
use Illuminate\Support\Str; |
6
|
|
|
use Modelarium\Laravel\Targets\MigrationGenerator; |
7
|
|
|
use Modelarium\Laravel\Targets\ModelGenerator; |
8
|
|
|
use Modelarium\Laravel\Targets\Interfaces\MigrationDirectiveInterface; |
9
|
|
|
use Modelarium\Laravel\Targets\Interfaces\ModelDirectiveInterface; |
10
|
|
|
|
11
|
|
|
class MigrationSoftDeletesDirective implements MigrationDirectiveInterface, ModelDirectiveInterface |
12
|
|
|
{ |
13
|
3 |
|
public static function processMigrationTypeDirective( |
14
|
|
|
MigrationGenerator $generator, |
15
|
|
|
\GraphQL\Language\AST\DirectiveNode $directive |
16
|
|
|
): void { |
17
|
3 |
|
$generator->createCode[] ='$table->softDeletes();'; |
18
|
3 |
|
} |
19
|
|
|
|
20
|
|
|
public static function processMigrationFieldDirective( |
21
|
|
|
MigrationGenerator $generator, |
22
|
|
|
\GraphQL\Type\Definition\FieldDefinition $field, |
23
|
|
|
\GraphQL\Language\AST\DirectiveNode $directive |
24
|
|
|
): void { |
25
|
|
|
// nothing |
26
|
|
|
} |
27
|
|
|
|
28
|
1 |
|
public static function processModelTypeDirective( |
29
|
|
|
ModelGenerator $generator, |
30
|
|
|
\GraphQL\Language\AST\DirectiveNode $directive |
31
|
|
|
): void { |
32
|
1 |
|
$generator->traits[] = '\Illuminate\Database\Eloquent\SoftDeletes'; |
33
|
1 |
|
} |
34
|
|
|
|
35
|
|
|
public static function processModelFieldDirective( |
36
|
|
|
ModelGenerator $generator, |
37
|
|
|
\GraphQL\Type\Definition\FieldDefinition $field, |
38
|
|
|
\GraphQL\Language\AST\DirectiveNode $directive |
39
|
|
|
): void { |
40
|
|
|
// nothing |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
public static function processModelRelationshipDirective( |
44
|
|
|
ModelGenerator $generator, |
45
|
|
|
\GraphQL\Type\Definition\FieldDefinition $field, |
46
|
|
|
\GraphQL\Language\AST\DirectiveNode $directive |
47
|
|
|
): string { |
48
|
|
|
// nothing |
49
|
|
|
return ''; |
50
|
|
|
} |
51
|
|
|
} |
52
|
|
|
|