Perbaikan Nama FIle Google Drive #72

Merged
arbi merged 1 commits from development into main 2026-10-02 16:08:00 +07:00
2 changed files with 5 additions and 4 deletions
@@ -606,7 +606,8 @@ class PengajuanAbsenController extends Controller
$pegawai->nip,
$pegawai->nama,
$request->tanggal,
$request->keterangan
$request->keterangan,
$namaFile
);
if (! $linkDrive) {
+3 -3
View File
@@ -21,7 +21,7 @@ class GoogleDriveService
$this->rootFolderId = (string) config('services.google_drive.folder_id');
}
public function uploadPdf(string $content, string $nip, string $namaPegawai, string $tanggal, string $namaKategori): string|false
public function uploadPdf(string $content, string $nip, string $namaPegawai, string $tanggal, string $namaKategori, ?string $namaFile = null): string|false
{
if (! $this->credentialsPath || ! file_exists($this->credentialsPath) || ! $this->rootFolderId) {
Log::error('GoogleDriveService: belum dikonfigurasi, upload dilewati.');
@@ -30,7 +30,7 @@ class GoogleDriveService
}
try {
$client = new Client();
$client = new Client;
$client->setAuthConfig($this->credentialsPath);
$client->addScope(Drive::DRIVE);
@@ -40,7 +40,7 @@ class GoogleDriveService
$pegawaiFolderId = $this->findOrCreateFolder($service, $this->sanitize("$nip - $namaPegawai"), $pengajuanPresensiFolderId);
$bulanFolderId = $this->findOrCreateFolder($service, Carbon::parse($tanggal)->translatedFormat('F Y'), $pegawaiFolderId);
$fileName = Carbon::parse($tanggal)->format('Y-m-d').'_'.$this->sanitize($namaKategori).'.pdf';
$fileName = $namaFile ?? Carbon::parse($tanggal)->format('Y-m-d').'_'.$this->sanitize($namaKategori).'.pdf';
$fileMetadata = new DriveFile([
'name' => $fileName,