This commit is contained in:
Konstantinos Arvanitakis
2026-07-01 18:35:39 +03:00
commit 9f58a36c82
44 changed files with 3848 additions and 0 deletions
+65
View File
@@ -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.");
}
}