Skip to content

Commit

Permalink
Fixed demo seeder
Browse files Browse the repository at this point in the history
  • Loading branch information
tobias-kuendig committed Aug 23, 2024
1 parent 9bfc435 commit 56f88cf
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
24 changes: 18 additions & 6 deletions updates/seeders/tables/CustomerTableSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,29 @@ protected function createUser(string $email, string $name, ?int $customerGroupId
{
[$firstname, $lastname] = explode(' ', $name);

$args = [
'password' => '12345678',
'password_confirmation' => '12345678',
];

$fillable = (new User())->getFillable();

if (in_array('surname', $fillable)) {
$args['name'] = $firstname;
$args['surname'] = $lastname;
} else {
$args['first_name'] = $firstname;
$args['last_name'] = $lastname;
}

$user = User::firstOrCreate([
'email' => $email,
'username' => $email,
], [
'password' => '12345678',
'password_confirmation' => '12345678',
'name' => $firstname,
'surname' => $lastname,
]);
], $args);

$user->offline_mall_customer_group_id = $customerGroupId;
$user->save();

$customer = Customer::create([
'firstname' => $firstname,
'lastname' => $lastname,
Expand Down
2 changes: 2 additions & 0 deletions updates/version.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -596,3 +596,5 @@ v3.4.4:
- 'Fixed customer group prices compatibility with RainLab.User 3.0'
v3.4.5:
- 'Fixed Stripe errors not showing up in the checkout form'
v3.4.6:
- 'Fixed demo seeder compatibility with all RainLab.User versions'

0 comments on commit 56f88cf

Please sign in to comment.