private function overrideExistingFiles(Collection $files, $source, $destination)
    {
        $answer = true;
        $filesFound = [];
        // map over to see if same filename already exist in destination
        $files->map(function (SplFileInfo $file) use ($source, $destination, &$filesFound) {

            $subDirectories = '';
            $fileDestination = $destination . $file->getFilename();

            // if file is in subdirectory - update destination path
            if ($source != $file->getPath() . $this->ds) {
                $subDirectories = str_replace($source, "", $file->getPath() . $this->ds);
                $fileDestination = $destination . $subDirectories . $file->getFilename();
            }

            // if file exist in destination
            if ($this->filesystem->exists($fileDestination)) {
                $filesFound [] = $subDirectories . $file->getFilename();
            }
        });

        // if files found
        if (count($filesFound) >= 1) {
            collect($filesFound)->each(function ($file) {
                $this->info(" - {$file}");
            });

            //$this->info("Destination: " . $destination);
            $answer = $this->confirm("Above is a list of the files that already exist. Override all files?");
        }

        return $answer;
    }
private function overrideExistingFiles(Collection $files, $source, $destination)
    {
        $answer = true;
        $filesFound = [];
        // map over to see if same filename already exist in destination
        $files->map(function (SplFileInfo $file) use ($source, $destination, &$filesFound) {

            $subDirectories = '';
            $fileDestination = $destination . $file->getFilename();

            // if file is in subdirectory - update destination path
            if ($source != $file->getPath() . $this->ds) {
                $subDirectories = str_replace($source, "", $file->getPath() . $this->ds);
                $fileDestination = $destination . $subDirectories . $file->getFilename();
            }

            // if file exist in destination
            if ($this->filesystem->exists($fileDestination)) {
                $filesFound [] = $subDirectories . $file->getFilename();
            }
        });

        // if files found
        if (count($filesFound) >= 1) {
            collect($filesFound)->each(function ($file) {
                $this->info(" - {$file}");
            });

            //$this->info("Destination: " . $destination);
            $answer = $this->confirm("Above is a list of the files that already exist. Override all files?");
        }

        return $answer;
    }
private function overrideExistingFiles ( Collection $ files , $ source , $ destination ) { $ answer = true ; $ filesFound = [ ] ; // map over to see if same filename already exist in destination $ files -> map ( function ( SplFileInfo $ file ) use ( $ source , $ destination , & $ filesFound ) { $ subDirectories = '' ; $ fileDestination = $ destination . $ file -> getFilename ( ) ; // if file is in subdirectory - update destination path if ( $ source != $ file -> getPath ( ) . $ this -> ds ) { $ subDirectories = str_replace ( $ source , "" , $ file -> getPath ( ) . $ this -> ds ) ; $ fileDestination = $ destination . $ subDirectories . $ file -> getFilename ( ) ; } // if file exist in destination if ( $ this -> filesystem -> exists ( $ fileDestination ) ) { $ filesFound [ ] = $ subDirectories . $ file -> getFilename ( ) ; } } ) ; // if files found if ( count ( $ filesFound ) >= 1 ) { collect ( $ filesFound ) -> each ( function ( $ file ) { $ this -> info ( " - {$file}" ) ; } ) ; //$this->info("Destination: " . $destination); $ answer = $ this -> confirm ( "Above is a list of the files that already exist. Override all files?" ) ; } return $ answer ; }
See if any files exist
Ask to override or not
@param Collection $files
@param            $source
@param            $destination
@return bool
See if any files exist Ask to override or not