mirror of
https://github.com/NamelessMC/Nameless
synced 2026-08-18 06:29:04 -04:00
* Create StyleCI config file * Disable `phpdoc_separation` * Apply fixes from StyleCI (#3476) Co-authored-by: StyleCI Bot <bot@styleci.io> * style: styleci fixes --------- Co-authored-by: StyleCI Bot <bot@styleci.io> Co-authored-by: Sam <samerton@users.noreply.github.com>
40 lines
1.3 KiB
PHP
40 lines
1.3 KiB
PHP
<?php
|
|
|
|
class ProfileFieldsDataSeeder extends Seeder
|
|
{
|
|
public array $tables = [
|
|
'nl2_users_profile_fields',
|
|
];
|
|
|
|
protected function run(DB $db, \Faker\Generator $faker): void
|
|
{
|
|
$profile_fields = $db->get('profile_fields', ['id', '<>', 0])->results();
|
|
|
|
foreach ($db->get('users', ['id', '<>', '0'])->results() as $user) {
|
|
foreach ($profile_fields as $profile_field) {
|
|
if (!$profile_field->required && $faker->boolean(30)) {
|
|
continue;
|
|
}
|
|
|
|
switch ($profile_field->type) {
|
|
case Fields::TEXT:
|
|
$value = $faker->text(30);
|
|
break;
|
|
case Fields::TEXTAREA:
|
|
$value = $faker->text(70);
|
|
break;
|
|
case Fields::DATE:
|
|
$value = $faker->date();
|
|
break;
|
|
}
|
|
|
|
$db->insert('users_profile_fields', [
|
|
'user_id' => $user->id,
|
|
'field_id' => $profile_field->id,
|
|
'value' => $value,
|
|
'updated' => $this->since($user->joined, $faker)->format('U'),
|
|
]);
|
|
}
|
|
}
|
|
}
|
|
}
|