]> _ Git - psq.git/commitdiff
UserImport
authorLouis Jeckel <louis.jeckel@outlook.com>
Tue, 9 Feb 2021 13:28:48 +0000 (14:28 +0100)
committerLouis Jeckel <louis.jeckel@outlook.com>
Tue, 9 Feb 2021 13:28:48 +0000 (14:28 +0100)
app/Imports/UsersImport.php

index 2bbdda4f6397303b065174ea8801a890dff0e5e2..a01fdf4de3b163257f55e053a4438e4dda60d7a6 100644 (file)
@@ -45,15 +45,18 @@ class UsersImport implements ToModel, WithValidation, WithHeadingRow
             ]);
         }
 
-        preg_match_all('/[0-9,+]+/', $row['phone'], $digits);
-        $phone = implode('', $digits[0]);
+
+        $phone = null;
+        if(preg_match_all('/[0-9,+]+/', $row['phone'] ?? "", $digits)){
+            $phone = implode('', $digits[0]);
+        }
 
         return new User([
             'first_name' => trim(Str::title($row['first_name'])),
             'last_name' => trim(Str::title($row['last_name'])),
             'email' => trim(Str::lower($row['email'])),
-            'position' => Str::title($row['position']),
-            'organization_id' => $org ? $org->id : null,
+            'position' => Str::title($row['position'] ?? ''),
+            'organization_id' => optional($org)->id,
             'address_line_1' => $row['address_line_1'],
             'postal_code' => $row['postal_code'],
             'city' => $row['city'],