protected function unpublishHook(Hook $hook)
    {
        $folders = (array) $hook->getComposerHookKey('assets', []);
        $basePath = $hook->getPath().'/';

        $filesystem = $this->filesystem;
        foreach ($folders as $location => $publish) {
            $publishPath = base_path($publish);
            if (!$realLocation = realpath($basePath.$location)) {
                continue;
            }

            if ($filesystem->isDirectory($realLocation)) {
                $allFiles = collect($this->filesystem->allFiles($realLocation))
                    ->map(function ($file) use ($realLocation) {
                        return substr($file->getRealPath(), strlen($realLocation) + 1);
                    });
            } else {
                $allFiles = collect([new \Symfony\Component\Finder\SplFileInfo(
                    $realLocation,
                    '',
                    basename($realLocation)
                )]);
            }

            $existingFiles = $allFiles->filter(function ($filename) use ($publishPath, $filesystem) {
                if ($filesystem->isDirectory($publishPath)) {
                    return $filesystem->exists($publishPath.'/'.$filename);
                }

                return $filesystem->exists($publishPath);
            });

            $existingFiles->each(function ($filename) use ($publishPath, $filesystem) {
                if ($filesystem->isDirectory($publishPath)) {
                    return $filesystem->delete($publishPath.'/'.$filename);
                }

                $filesystem->delete($publishPath);
            });
        }
    }
protected function unpublishHook(Hook $hook)
    {
        $folders = (array) $hook->getComposerHookKey('assets', []);
        $basePath = $hook->getPath().'/';

        $filesystem = $this->filesystem;
        foreach ($folders as $location => $publish) {
            $publishPath = base_path($publish);
            if (!$realLocation = realpath($basePath.$location)) {
                continue;
            }

            if ($filesystem->isDirectory($realLocation)) {
                $allFiles = collect($this->filesystem->allFiles($realLocation))
                    ->map(function ($file) use ($realLocation) {
                        return substr($file->getRealPath(), strlen($realLocation) + 1);
                    });
            } else {
                $allFiles = collect([new \Symfony\Component\Finder\SplFileInfo(
                    $realLocation,
                    '',
                    basename($realLocation)
                )]);
            }

            $existingFiles = $allFiles->filter(function ($filename) use ($publishPath, $filesystem) {
                if ($filesystem->isDirectory($publishPath)) {
                    return $filesystem->exists($publishPath.'/'.$filename);
                }

                return $filesystem->exists($publishPath);
            });

            $existingFiles->each(function ($filename) use ($publishPath, $filesystem) {
                if ($filesystem->isDirectory($publishPath)) {
                    return $filesystem->delete($publishPath.'/'.$filename);
                }

                $filesystem->delete($publishPath);
            });
        }
    }
protected function unpublishHook ( Hook $ hook ) { $ folders = ( array ) $ hook -> getComposerHookKey ( 'assets' , [ ] ) ; $ basePath = $ hook -> getPath ( ) . '/' ; $ filesystem = $ this -> filesystem ; foreach ( $ folders as $ location => $ publish ) { $ publishPath = base_path ( $ publish ) ; if ( ! $ realLocation = realpath ( $ basePath . $ location ) ) { continue ; } if ( $ filesystem -> isDirectory ( $ realLocation ) ) { $ allFiles = collect ( $ this -> filesystem -> allFiles ( $ realLocation ) ) -> map ( function ( $ file ) use ( $ realLocation ) { return substr ( $ file -> getRealPath ( ) , strlen ( $ realLocation ) + 1 ) ; } ) ; } else { $ allFiles = collect ( [ new \ Symfony \ Component \ Finder \ SplFileInfo ( $ realLocation , '' , basename ( $ realLocation ) ) ] ) ; } $ existingFiles = $ allFiles -> filter ( function ( $ filename ) use ( $ publishPath , $ filesystem ) { if ( $ filesystem -> isDirectory ( $ publishPath ) ) { return $ filesystem -> exists ( $ publishPath . '/' . $ filename ) ; } return $ filesystem -> exists ( $ publishPath ) ; } ) ; $ existingFiles -> each ( function ( $ filename ) use ( $ publishPath , $ filesystem ) { if ( $ filesystem -> isDirectory ( $ publishPath ) ) { return $ filesystem -> delete ( $ publishPath . '/' . $ filename ) ; } $ filesystem -> delete ( $ publishPath ) ; } ) ; } }
Unpublish assets found for a specific hook.

@param \Larapack\Hooks\Hook $hook
Unpublish assets found for a specific hook .