Skip to content

Commit

Permalink
fix UserFactory
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaomlove committed Feb 26, 2024
1 parent 86dd3ef commit 0f551d5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
1 change: 1 addition & 0 deletions app/Console/Commands/UserGenerate.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public function handle()
$log = "num: $num";
if (!$num) {
$this->error("$log, no num!");
return Command::SUCCESS;
}
$size = 1000;
$total = 0;
Expand Down
12 changes: 5 additions & 7 deletions database/factories/UserFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,8 @@

class UserFactory extends Factory
{
private string $defaultStyleSheet;
private static string $defaultStyleSheet = "";

public function __construct()
{
do_log("UserFactory __construct");
$this->defaultStyleSheet = get_setting("main.defstylesheet");
}

/**
* The name of the factory's corresponding model.
Expand All @@ -34,13 +29,16 @@ public function definition()
$password = "123456";
$secret = mksecret();
$passhash = md5($secret . $password . $secret);
if (self::$defaultStyleSheet == "") {
self::$defaultStyleSheet = get_setting("main.defstylesheet");
}
return [
'username' => $this->faker->name,
'email' => $this->faker->unique()->safeEmail,
'secret' => mksecret(),
'editsecret' => "",
'passhash' => $passhash,
'stylesheet' => $this->defaultStyleSheet,
'stylesheet' => self::$defaultStyleSheet,
'added' => now()->toDateTimeString(),
'status' => User::STATUS_CONFIRMED,
'class' => random_int(intval(User::CLASS_USER), intval(User::CLASS_SYSOP))
Expand Down

0 comments on commit 0f551d5

Please sign in to comment.