[ 'mime' => 'image/png', ], 'ai' => [ 'mime' => 'application/postscript', ], 'svg' => [ 'mime' => 'image/svg+xml', ], 'jpeg' => [ 'mime' => 'image/jpeg', ], 'tiff' => [ 'mime' => 'image/tiff', ], 'pdf' => [ 'mime' => 'application/pdf', ], 'gif' => [ 'mime' => 'image/gif', ], 'psd' => [ 'mime' => 'image/vnd.adobe.photoshop', ], 'txt' => [ 'mime' => 'text/plain', ], 'doc' => [ 'mime' => 'application/msword', ], 'xls' => [ 'mime' => 'application/vnd.ms-excel', ], 'ppt' => [ 'mime' => 'application/vnd.ms-powerpoint', ], 'xlsx' => [ 'mime' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', ], 'docx' => [ 'mime' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', ], 'pptx' => [ 'mime' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation', ], ]; /** * @var array */ public static $extraExtensions = [ 'jpg' => 'jpeg', 'tif' => 'tiff', ]; public function getEntityType() { return self::class; } public function documentable() { return $this->morphTo(); } public function generateUrl($absolute = false) { $url = Storage::disk($this->disk)->url($this->url); if ($url && $absolute) { return url($url); } if ($url) { return $url; } return null; } public function generateRoute($absolute = false) { return route('api.documents.show', ['document' => $this->hashed_id]).'/download'; } public function deleteFile() { Storage::disk($this->disk)->delete($this->url); } public function filePath() { return Storage::disk($this->disk)->url($this->url); } }