diff --git a/src/app/Enums/ReportFormatEnum.php b/src/app/Enums/ReportFormatEnum.php index 51168db..172230d 100644 --- a/src/app/Enums/ReportFormatEnum.php +++ b/src/app/Enums/ReportFormatEnum.php @@ -29,4 +29,45 @@ class ReportFormatEnum 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'; + } + } } \ No newline at end of file