Informando quais formatos podem entrar no fluxo de download e permitindo identificar o mime do formato

laravel-11
jtfnetoo 3 years ago
parent 6aeed9d0b7
commit 9aee3c0d99

@ -29,4 +29,45 @@ class ReportFormatEnum
self::XLSX, self::XLSX,
]; ];
} }
/**
* @return string[]
*/
public static function downloadable(): array
{
return [
self::PDF,
self::XML,
self::CSV,
self::DOCX,
self::ODT,
self::ODS,
self::XLSX,
];
}
/**
* @param string $format
* @return string
*/
public static function getMimeType(string $format): string
{
switch ($format) {
case self::PDF:
return 'application/pdf';
case self::XML:
return 'application/xml';
case self::CSV:
return 'text/csv';
case self::DOCX:
return 'application/vnd.openxmlformats-officedocument.wordprocessingml.document';
case self::ODT:
return 'application/vnd.oasis.opendocument.text';
case self::XLSX:
case self::ODS:
return 'application/vnd.oasis.opendocument.spreadsheet';
default:
return 'text/html';
}
}
} }
Loading…
Cancel
Save