|
|
|
@@ -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,
|
|
|
|
|