From 56f88cfa1c9a508d266b73a1e9bc8e183408c4cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20K=C3=BCndig?= Date: Fri, 23 Aug 2024 08:40:30 +0200 Subject: [PATCH] Fixed demo seeder --- .../seeders/tables/CustomerTableSeeder.php | 24 ++++++++++++++----- updates/version.yaml | 2 ++ 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/updates/seeders/tables/CustomerTableSeeder.php b/updates/seeders/tables/CustomerTableSeeder.php index 4a7b8e366..00af3b4d9 100644 --- a/updates/seeders/tables/CustomerTableSeeder.php +++ b/updates/seeders/tables/CustomerTableSeeder.php @@ -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, diff --git a/updates/version.yaml b/updates/version.yaml index 009278336..31cccc4fe 100644 --- a/updates/version.yaml +++ b/updates/version.yaml @@ -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'