File tree Expand file tree Collapse file tree 3 files changed +18
-3
lines changed Expand file tree Collapse file tree 3 files changed +18
-3
lines changed Original file line number Diff line number Diff line change @@ -58,7 +58,7 @@ class User extends Authenticatable
58
58
}
59
59
60
60
// optional
61
- public function anonymizableCondition()
61
+ public function anonymizableCondition(): Builder
62
62
{
63
63
return self::withTrashed()->where('something', '=>', '...');
64
64
}
@@ -70,6 +70,11 @@ Anonymization is performed using command:
70
70
php artisan db:anonymize
71
71
```
72
72
73
+ Or on specific models:
74
+ ``` bash
75
+ php artisan db:anonymize --model=\\ App\U ser --model=\\ App\\ Profile
76
+ ```
77
+
73
78
## License
74
79
75
80
The MIT License (MIT). Please see [ License File] ( LICENSE ) for more information.
Original file line number Diff line number Diff line change 1
1
<?php
2
2
3
- namespace Outsidaz \LaravelDataAnonymization ;;
3
+ namespace Outsidaz \LaravelDataAnonymization ;
4
4
use Faker \Factory ;
5
5
use Faker \Generator ;
6
6
use Illuminate \Database \Eloquent \Builder ;
Original file line number Diff line number Diff line change @@ -15,9 +15,10 @@ class AnonymizerCommand extends Command
15
15
*
16
16
* @var string
17
17
*/
18
- protected $ name = 'db:anonymize ' ;
18
+ protected $ signature = 'db:anonymize {--model=*} ' ;
19
19
20
20
public $ description = 'Anonymize specific data of the database ' ;
21
+
21
22
private Anonymizer $ service ;
22
23
23
24
@@ -30,10 +31,19 @@ public function __construct()
30
31
31
32
public function handle (): int
32
33
{
34
+ $ specified = $ this ->option ('model ' );
35
+
33
36
$ anonymizationStart = microtime (true );
34
37
35
38
$ anonymizableClasses = $ this ->service ->getAnonymizableClasses ();
36
39
40
+ if ($ specified ) {
41
+ $ anonymizableClasses =array_filter (
42
+ $ anonymizableClasses ,
43
+ fn ($ class ) => in_array ($ class , $ specified , true )
44
+ );
45
+ }
46
+
37
47
$ this ->warn ('Anonymization started ' );
38
48
39
49
foreach ($ anonymizableClasses as $ anonymizableClass ) {
You can’t perform that action at this time.
0 commit comments