Skip to content

Commit

Permalink
Add command to anonymize data
Browse files Browse the repository at this point in the history
  • Loading branch information
karlomikus committed Dec 11, 2024
1 parent 347dac5 commit 33bfe27
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions app/Console/Commands/BarAnon.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php

declare(strict_types=1);

namespace Kami\Cocktail\Console\Commands;

use Kami\Cocktail\Models\User;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Hash;

class BarAnon extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'bar:anon';

/**
* The console command description.
*
* @var string
*/
protected $description = '[DEV] Anonymize data';

/**
* Execute the console command.
*
* @return int
*/
public function handle()
{
$users = User::all();

foreach ($users as $user) {
$user->email = 'email' . $user->id . '@example.com';
$user->name = 'User ' . $user->id;
$user->password = Hash::make('Test12345');
$user->save();
}

$this->output->success('Done!');

return Command::SUCCESS;
}
}

0 comments on commit 33bfe27

Please sign in to comment.