Merge pull request 'Perbaikan Nama FIle Google Drive' (#72) from development into main

Reviewed-on: #72
This commit was merged in pull request #72.
This commit is contained in:
2026-10-02 16:07:59 +07:00
2 changed files with 5 additions and 4 deletions
@@ -606,7 +606,8 @@ class PengajuanAbsenController extends Controller
$pegawai->nip, $pegawai->nip,
$pegawai->nama, $pegawai->nama,
$request->tanggal, $request->tanggal,
$request->keterangan $request->keterangan,
$namaFile
); );
if (! $linkDrive) { if (! $linkDrive) {
+3 -3
View File
@@ -21,7 +21,7 @@ class GoogleDriveService
$this->rootFolderId = (string) config('services.google_drive.folder_id'); $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) { if (! $this->credentialsPath || ! file_exists($this->credentialsPath) || ! $this->rootFolderId) {
Log::error('GoogleDriveService: belum dikonfigurasi, upload dilewati.'); Log::error('GoogleDriveService: belum dikonfigurasi, upload dilewati.');
@@ -30,7 +30,7 @@ class GoogleDriveService
} }
try { try {
$client = new Client(); $client = new Client;
$client->setAuthConfig($this->credentialsPath); $client->setAuthConfig($this->credentialsPath);
$client->addScope(Drive::DRIVE); $client->addScope(Drive::DRIVE);
@@ -40,7 +40,7 @@ class GoogleDriveService
$pegawaiFolderId = $this->findOrCreateFolder($service, $this->sanitize("$nip - $namaPegawai"), $pengajuanPresensiFolderId); $pegawaiFolderId = $this->findOrCreateFolder($service, $this->sanitize("$nip - $namaPegawai"), $pengajuanPresensiFolderId);
$bulanFolderId = $this->findOrCreateFolder($service, Carbon::parse($tanggal)->translatedFormat('F Y'), $pegawaiFolderId); $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([ $fileMetadata = new DriveFile([
'name' => $fileName, 'name' => $fileName,