Update fictionalize command
This commit is contained in:
parent
1af9715682
commit
aa967c317b
|
|
@ -8,48 +8,80 @@ use App\Models\User;
|
||||||
use Faker\Factory;
|
use Faker\Factory;
|
||||||
use Illuminate\Console\Command;
|
use Illuminate\Console\Command;
|
||||||
|
|
||||||
/**
|
|
||||||
* @codeCoverageIgnore
|
|
||||||
*/
|
|
||||||
class fictionalize extends Command
|
class fictionalize extends Command
|
||||||
{
|
{
|
||||||
/**
|
protected $signature = 'audition:fictionalize
|
||||||
* The name and signature of the console command.
|
{--students : Fictionalize student names}
|
||||||
*
|
{--schools : Fictionalize school names}
|
||||||
* @var string
|
{--users : Fictionalize user data}
|
||||||
*/
|
{--all : Fictionalize all data types}';
|
||||||
protected $signature = 'audition:fictionalize';
|
|
||||||
|
|
||||||
/**
|
protected $description = 'Replace real names with fictional data for specified entity types';
|
||||||
* The console command description.
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
protected $description = 'Command description';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Execute the console command.
|
|
||||||
*/
|
|
||||||
public function handle()
|
public function handle()
|
||||||
{
|
{
|
||||||
$faker = Factory::create();
|
$faker = Factory::create();
|
||||||
foreach (Student::all() as $student) {
|
|
||||||
$student->first_name = $faker->firstName();
|
// If no options are specified or --all is used, process everything
|
||||||
$student->last_name = $faker->lastName();
|
$processAll = $this->option('all') ||
|
||||||
$student->save();
|
(! $this->option('students') && ! $this->option('schools') && ! $this->option('users'));
|
||||||
|
|
||||||
|
if ($processAll || $this->option('students')) {
|
||||||
|
$this->info('Fictionalizing students...');
|
||||||
|
$bar = $this->output->createProgressBar(Student::count());
|
||||||
|
|
||||||
|
Student::chunk(100, function ($students) use ($faker, $bar) {
|
||||||
|
foreach ($students as $student) {
|
||||||
|
$student->update([
|
||||||
|
'first_name' => $faker->firstName(),
|
||||||
|
'last_name' => $faker->lastName(),
|
||||||
|
]);
|
||||||
|
$bar->advance();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
$bar->finish();
|
||||||
|
$this->newLine();
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (School::all() as $school) {
|
if ($processAll || $this->option('schools')) {
|
||||||
$school->name = $faker->city().' High School';
|
$this->info('Fictionalizing schools...');
|
||||||
$school->save();
|
$bar = $this->output->createProgressBar(School::count());
|
||||||
|
|
||||||
|
School::chunk(100, function ($schools) use ($faker, $bar) {
|
||||||
|
foreach ($schools as $school) {
|
||||||
|
$school->update([
|
||||||
|
'name' => $faker->city().' High School',
|
||||||
|
]);
|
||||||
|
$bar->advance();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
$bar->finish();
|
||||||
|
$this->newLine();
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (User::where('email', '!=', 'matt@mattyoung.us')->get() as $user) {
|
if ($processAll || $this->option('users')) {
|
||||||
$user->email = $faker->email();
|
$this->info('Fictionalizing users...');
|
||||||
$user->first_name = $faker->firstName();
|
$bar = $this->output->createProgressBar(User::where('email', '!=', 'matt@mattyoung.us')->count());
|
||||||
$user->last_name = $faker->lastName();
|
|
||||||
$user->cell_phone = $faker->phoneNumber();
|
User::where('email', '!=', 'matt@mattyoung.us')
|
||||||
$user->save();
|
->chunk(100, function ($users) use ($faker, $bar) {
|
||||||
}
|
foreach ($users as $user) {
|
||||||
|
$user->update([
|
||||||
|
'email' => $faker->unique()->email(),
|
||||||
|
'first_name' => $faker->firstName(),
|
||||||
|
'last_name' => $faker->lastName(),
|
||||||
|
'cell_phone' => $faker->phoneNumber(),
|
||||||
|
]);
|
||||||
|
$bar->advance();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
$bar->finish();
|
||||||
|
$this->newLine();
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->info('Fictionalization complete!');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@
|
||||||
@foreach($entries as $entry)
|
@foreach($entries as $entry)
|
||||||
<tr>
|
<tr>
|
||||||
<x-table.td>
|
<x-table.td>
|
||||||
{{ $audition->name }} {{ $entry->draw_number }}
|
{{ $audition->name }} {{ $entry->draw_number }}<br class="md:hidden">
|
||||||
@if($audition->prelimDefinition && ! $entry->hasFlag('no_show'))
|
@if($audition->prelimDefinition && ! $entry->hasFlag('no_show'))
|
||||||
@if($entry->hasFlag('failed_prelim'))
|
@if($entry->hasFlag('failed_prelim'))
|
||||||
<span
|
<span
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue