Init
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Core\Command;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
|
||||
class AnonymizeCommand extends Command
|
||||
{
|
||||
protected $signature = "boboko:anonymize";
|
||||
|
||||
protected $description = "Anonymize personal data in users and lunar_customers";
|
||||
|
||||
public function handle(): void
|
||||
{
|
||||
if (!app()->environment("local")) {
|
||||
$this->error(
|
||||
"This command can only be run in the local environment.",
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
if (
|
||||
!$this->confirm(
|
||||
"This will permanently overwrite personal data. Continue?",
|
||||
)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
DB::table("users")
|
||||
->get()
|
||||
->each(function ($user) {
|
||||
DB::table("users")
|
||||
->where("id", $user->id)
|
||||
->update([
|
||||
"name" => "User {$user->id}",
|
||||
"email" => "user_{$user->id}@example.com",
|
||||
"password" => Hash::make("password"),
|
||||
"remember_token" => null,
|
||||
]);
|
||||
});
|
||||
|
||||
$this->info("Users anonymized.");
|
||||
|
||||
DB::table("lunar_customers")
|
||||
->get()
|
||||
->each(function ($customer) {
|
||||
DB::table("lunar_customers")
|
||||
->where("id", $customer->id)
|
||||
->update([
|
||||
"title" => null,
|
||||
"first_name" => "Customer",
|
||||
"last_name" => (string) $customer->id,
|
||||
"company_name" => null,
|
||||
"tax_identifier" => null,
|
||||
"account_ref" => null,
|
||||
"meta" => null,
|
||||
]);
|
||||
});
|
||||
|
||||
$this->info("Customers anonymized.");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user