34 lines
859 B
PHP
34 lines
859 B
PHP
<?php
|
|
|
|
namespace classes;
|
|
|
|
use interfaces\minio_wash_certificates_i;
|
|
use traits\minio_t;
|
|
|
|
class wash_certificate_store implements minio_wash_certificates_i
|
|
{
|
|
use minio_t;
|
|
|
|
public function __construct()
|
|
{
|
|
self::setBucket('truckwashdev'); // Change this to washcertificates when in production
|
|
}
|
|
|
|
/**
|
|
* @inheritDoc
|
|
*/
|
|
public function washCertificateExists(string $certificate_id): bool
|
|
{
|
|
// Check if the file exists
|
|
$objects = self::getS3Client()->listObjects([
|
|
'Bucket' => self::getBucket(),
|
|
'Prefix' => 'wash_certificate_' . $certificate_id . '.pdf'
|
|
]);
|
|
return count($objects['Contents'] ?? []) > 0;
|
|
}
|
|
|
|
public function getWashCertificateDownload(int $id): string
|
|
{
|
|
return self::getPresignedUrl('wash_certificate_' . $id . '.pdf');
|
|
}
|
|
} |