src/Traits/WorksWithFileUploads.php
protected function handleMultipleFileUploads(Request $request, Model $model, $paramName, $uploadedFiles, $relativePath)
    {
        $this->_checkFileRelationExists($model, $paramName);

        $data = $request->attributes->all();
        $fileBag = $request->files;
        foreach ($uploadedFiles as $index => $uploadedFile) {
            if (!$uploadedFile->isValid()) {
                throw new UploadException($uploadedFile->getError());
            }

            $filename = $this->getFilename($uploadedFile);
            $storagePath = $this->getStoragePath($relativePath);
            $this->moveUploadedFile($uploadedFile, $filename, $storagePath);

            $location = $relativePath.$filename;

            if (count($fileBag->get($paramName)) > 1) {
                $data[$paramName][$index] = [$this->getLocationColumn() => $location];
            } else {
                $data[$paramName][$this->getLocationColumn()] = $location;
            }

            $request->merge($data);
        }
    }
protected function handleMultipleFileUploads(Request $request, Model $model, $paramName, $uploadedFiles, $relativePath)
    {
        $this->_checkFileRelationExists($model, $paramName);

        $data = $request->attributes->all();
        $fileBag = $request->files;
        foreach ($uploadedFiles as $index => $uploadedFile) {
            if (!$uploadedFile->isValid()) {
                throw new UploadException($uploadedFile->getError());
            }

            $filename = $this->getFilename($uploadedFile);
            $storagePath = $this->getStoragePath($relativePath);
            $this->moveUploadedFile($uploadedFile, $filename, $storagePath);

            $location = $relativePath.$filename;

            if (count($fileBag->get($paramName)) > 1) {
                $data[$paramName][$index] = [$this->getLocationColumn() => $location];
            } else {
                $data[$paramName][$this->getLocationColumn()] = $location;
            }

            $request->merge($data);
        }
    }
protected function handleMultipleFileUploads ( Request $ request , Model $ model , $ paramName , $ uploadedFiles , $ relativePath ) { $ this -> _checkFileRelationExists ( $ model , $ paramName ) ; $ data = $ request -> attributes -> all ( ) ; $ fileBag = $ request -> files ; foreach ( $ uploadedFiles as $ index => $ uploadedFile ) { if ( ! $ uploadedFile -> isValid ( ) ) { throw new UploadException ( $ uploadedFile -> getError ( ) ) ; } $ filename = $ this -> getFilename ( $ uploadedFile ) ; $ storagePath = $ this -> getStoragePath ( $ relativePath ) ; $ this -> moveUploadedFile ( $ uploadedFile , $ filename , $ storagePath ) ; $ location = $ relativePath . $ filename ; if ( count ( $ fileBag -> get ( $ paramName ) ) > 1 ) { $ data [ $ paramName ] [ $ index ] = [ $ this -> getLocationColumn ( ) => $ location ] ; } else { $ data [ $ paramName ] [ $ this -> getLocationColumn ( ) ] = $ location ; } $ request -> merge ( $ data ) ; } }
Handle multiple file uploads.

@param Request $request       The Request object.
@param Model   $model         The eloquent model.
@param string  $paramName     The name of the file param.
@param array   $uploadedFiles An array of UploadedFile objects.
@param string  $relativePath  The file uploads relative path.

@return void
Handle multiple file uploads .