|
@@ -7,8 +7,7 @@ use App\Enums\UserTypeEnum;
|
|
|
use App\Imports\AssociadoImport;
|
|
use App\Imports\AssociadoImport;
|
|
|
use App\Models\User;
|
|
use App\Models\User;
|
|
|
use Carbon\Carbon;
|
|
use Carbon\Carbon;
|
|
|
-use Illuminate\Support\Facades\Hash;
|
|
|
|
|
-use Illuminate\Support\Str;
|
|
|
|
|
|
|
+use Illuminate\Support\Facades\Log;
|
|
|
use Maatwebsite\Excel\Facades\Excel;
|
|
use Maatwebsite\Excel\Facades\Excel;
|
|
|
|
|
|
|
|
class AssociadoImportService
|
|
class AssociadoImportService
|
|
@@ -54,7 +53,7 @@ class AssociadoImportService
|
|
|
$changed = true;
|
|
$changed = true;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if($user->admission_date?->toDateString() !== $admissionDate) {
|
|
|
|
|
|
|
+ if ($admissionDate !== null && $user->admission_date?->toDateString() !== $admissionDate) {
|
|
|
$user->admission_date = $admissionDate;
|
|
$user->admission_date = $admissionDate;
|
|
|
$changed = true;
|
|
$changed = true;
|
|
|
}
|
|
}
|
|
@@ -77,7 +76,6 @@ class AssociadoImportService
|
|
|
} else {
|
|
} else {
|
|
|
User::create([
|
|
User::create([
|
|
|
'name' => $name,
|
|
'name' => $name,
|
|
|
- 'password' => Hash::make(Str::random(32)),
|
|
|
|
|
'type' => UserTypeEnum::ASSOCIADO,
|
|
'type' => UserTypeEnum::ASSOCIADO,
|
|
|
'status' => UserStatusEnum::ACTIVE,
|
|
'status' => UserStatusEnum::ACTIVE,
|
|
|
'registration' => $registration,
|
|
'registration' => $registration,
|
|
@@ -98,12 +96,14 @@ class AssociadoImportService
|
|
|
'excluded_at' => now(),
|
|
'excluded_at' => now(),
|
|
|
]);
|
|
]);
|
|
|
|
|
|
|
|
- return [
|
|
|
|
|
|
|
+ $result = [
|
|
|
'total' => $rows->count(),
|
|
'total' => $rows->count(),
|
|
|
'created' => $created,
|
|
'created' => $created,
|
|
|
'updated' => $updated,
|
|
'updated' => $updated,
|
|
|
'inactivated' => $inactivated,
|
|
'inactivated' => $inactivated,
|
|
|
];
|
|
];
|
|
|
|
|
+
|
|
|
|
|
+ return $result;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public function syncAfastamentosFromExcel(string $filePath, int $byUserId): array
|
|
public function syncAfastamentosFromExcel(string $filePath, int $byUserId): array
|
|
@@ -147,7 +147,6 @@ class AssociadoImportService
|
|
|
} else {
|
|
} else {
|
|
|
User::create([
|
|
User::create([
|
|
|
'name' => $name,
|
|
'name' => $name,
|
|
|
- 'password' => Hash::make(Str::random(32)),
|
|
|
|
|
'type' => UserTypeEnum::ASSOCIADO,
|
|
'type' => UserTypeEnum::ASSOCIADO,
|
|
|
'status' => UserStatusEnum::ON_LEAVE,
|
|
'status' => UserStatusEnum::ON_LEAVE,
|
|
|
'registration' => $registration,
|
|
'registration' => $registration,
|