'docx', self::DOCXOLD_MIME_TYPE => 'docx', self::DOCX_WPS_TYPE => 'docx', self::DOC_MIME_TYPE => 'doc', self::RTF_MIME_TYPE => 'rtf', self::APPLICATION_RTF_MIME_TYPE => 'rtf', self::ODT_MIME_TYPE => 'odt', self::PDF_MIME_TYPE => 'pdf', self::PDF_WPS_MIME_TYPE => 'pdf', self::PLAIN_TEXT_TYPE => 'txt', ]; public function __construct($id, $fileResultType, $mimeType, $document, $fromRequest = true) { $this->id = $id; $this->fileResultType = $fileResultType; $this->mimeType = $mimeType; $this->document = $document; $this->fromRequest = $fromRequest; } public function handle() { $storage = Storage::disk('local'); if (!array_key_exists($this->mimeType, $this->supportedFiles)) { throw new \Exception('File not supported.'); } $type = $this->supportedFiles[$this->mimeType]; $id = str_replace(' ', '_', $this->id); $path = $storage->putFileAs("contracts/$id", $this->document, "document.$type"); IngestDocuments::dispatch( $this->id, $this->fileResultType, $path, $type, $this->fromRequest ); } }