public function handleDownload()
    {
        $this->storeUsers();
        $this->storePosts();
        $this->storeTags();
        $this->storePostTag();
        $this->storeMigrations();
        $this->storeUploads();
        $this->storePasswordResets();
        $this->storeSettings();
        $date = date('Y-m-d');
        $path = storage_path($date.'-canvas-archive');
        $filename = sprintf('%s.zip', $path);
        $zip = new \ZipArchive();
        $zip->open($filename, \ZipArchive::CREATE);
        $files = new \RecursiveIteratorIterator(
            new \RecursiveDirectoryIterator($path),
            \RecursiveIteratorIterator::LEAVES_ONLY
        );
        foreach ($files as $name => $file) {
            if (! $file->isDir()) {
                $filePath = $file->getRealPath();
                $relativePath = substr($filePath, strlen($path) + 1);
                $zip->addFile($filePath, $relativePath);
            }
        }
        $zip->close();
        \File::deleteDirectory(storage_path($date.'-canvas-archive'));

        return response()->download(storage_path($date.'-canvas-archive.zip'))->deleteFileAfterSend(true);
    }
public function handleDownload()
    {
        $this->storeUsers();
        $this->storePosts();
        $this->storeTags();
        $this->storePostTag();
        $this->storeMigrations();
        $this->storeUploads();
        $this->storePasswordResets();
        $this->storeSettings();
        $date = date('Y-m-d');
        $path = storage_path($date.'-canvas-archive');
        $filename = sprintf('%s.zip', $path);
        $zip = new \ZipArchive();
        $zip->open($filename, \ZipArchive::CREATE);
        $files = new \RecursiveIteratorIterator(
            new \RecursiveDirectoryIterator($path),
            \RecursiveIteratorIterator::LEAVES_ONLY
        );
        foreach ($files as $name => $file) {
            if (! $file->isDir()) {
                $filePath = $file->getRealPath();
                $relativePath = substr($filePath, strlen($path) + 1);
                $zip->addFile($filePath, $relativePath);
            }
        }
        $zip->close();
        \File::deleteDirectory(storage_path($date.'-canvas-archive'));

        return response()->download(storage_path($date.'-canvas-archive.zip'))->deleteFileAfterSend(true);
    }
public function handleDownload ( ) { $ this -> storeUsers ( ) ; $ this -> storePosts ( ) ; $ this -> storeTags ( ) ; $ this -> storePostTag ( ) ; $ this -> storeMigrations ( ) ; $ this -> storeUploads ( ) ; $ this -> storePasswordResets ( ) ; $ this -> storeSettings ( ) ; $ date = date ( 'Y-m-d' ) ; $ path = storage_path ( $ date . '-canvas-archive' ) ; $ filename = sprintf ( '%s.zip' , $ path ) ; $ zip = new \ ZipArchive ( ) ; $ zip -> open ( $ filename , \ ZipArchive :: CREATE ) ; $ files = new \ RecursiveIteratorIterator ( new \ RecursiveDirectoryIterator ( $ path ) , \ RecursiveIteratorIterator :: LEAVES_ONLY ) ; foreach ( $ files as $ name => $ file ) { if ( ! $ file -> isDir ( ) ) { $ filePath = $ file -> getRealPath ( ) ; $ relativePath = substr ( $ filePath , strlen ( $ path ) + 1 ) ; $ zip -> addFile ( $ filePath , $ relativePath ) ; } } $ zip -> close ( ) ; \ File :: deleteDirectory ( storage_path ( $ date . '-canvas-archive' ) ) ; return response ( ) -> download ( storage_path ( $ date . '-canvas-archive.zip' ) ) -> deleteFileAfterSend ( true ) ; }
Create and download an archive of all existing data.

@return \Illuminate\View\View
Create and download an archive of all existing data .