src/Traits/WorksWithFileUploads.php
public function uploadFiles(Request $request, Model $model, $relativePath = null)
    {
        if (!$relativePath) {
            $relativePath = $this->getDefaultRelativePath();
        }

        $fileBag = $request->files;
        foreach ($fileBag->all() as $paramName => $uploadedFiles) {
            $attributes = $model->getAttributes();
            if (array_key_exists($paramName, $attributes)) {
                $this->handleNonMultipleFileUploads($model, $paramName, $uploadedFiles, $relativePath);
            } else {
                $this->handleMultipleFileUploads($request, $model, $paramName, $uploadedFiles, $relativePath);
            }
        }

        return $request;
    }
public function uploadFiles(Request $request, Model $model, $relativePath = null)
    {
        if (!$relativePath) {
            $relativePath = $this->getDefaultRelativePath();
        }

        $fileBag = $request->files;
        foreach ($fileBag->all() as $paramName => $uploadedFiles) {
            $attributes = $model->getAttributes();
            if (array_key_exists($paramName, $attributes)) {
                $this->handleNonMultipleFileUploads($model, $paramName, $uploadedFiles, $relativePath);
            } else {
                $this->handleMultipleFileUploads($request, $model, $paramName, $uploadedFiles, $relativePath);
            }
        }

        return $request;
    }
public function uploadFiles ( Request $ request , Model $ model , $ relativePath = null ) { if ( ! $ relativePath ) { $ relativePath = $ this -> getDefaultRelativePath ( ) ; } $ fileBag = $ request -> files ; foreach ( $ fileBag -> all ( ) as $ paramName => $ uploadedFiles ) { $ attributes = $ model -> getAttributes ( ) ; if ( array_key_exists ( $ paramName , $ attributes ) ) { $ this -> handleNonMultipleFileUploads ( $ model , $ paramName , $ uploadedFiles , $ relativePath ) ; } else { $ this -> handleMultipleFileUploads ( $ request , $ model , $ paramName , $ uploadedFiles , $ relativePath ) ; } } return $ request ; }
Upload request files and update or create relations handling array type request data.

@param Request     $request      The Request object.
@param Model       $model        The eloquent model.
@param string|null $relativePath The file uploads relative path.

@return Request
Upload request files and update or create relations handling array type request data .