app/Utils/Util.php
/**
     * Uploads document to the server if present in the request
     * @param obj $request, string $file_name, string dir_name
     *
     * @return string
     */
Uploads document to the server if present in the request
@param obj $request, string $file_name, string dir_name

@return string
Uploads document to the server if present in the request @param obj $request string $file_name string dir_name @return string
public function uploadFile($request, $file_name, $dir_name, $file_type = 'document')
    {
        if (config('app.env') == 'demo') {
            return null;
        }
        $uploaded_file_name = null;
        if ($request->hasFile($file_name) && $request->file($file_name)->isValid()) {
            if ($file_type == 'image') {
                if (strpos($request->$file_name->getClientMimeType(), 'image/') === false) {
                    throw new \Exception("Invalid image file");
                }
            }
            if ($request->$file_name->getSize() <= config('constants.document_size_limit')) {
                $new_file_name = time() . '_' . $request->$file_name->getClientOriginalName();
                if ($request->$file_name->storeAs($dir_name, $new_file_name)) {
                    $uploaded_file_name = $new_file_name;
                }
            }
        }
        return $uploaded_file_name;
    }
public function uploadFile ( $ request , $ file_name , $ dir_name , $ file_type = 'document' ) { if ( config ( 'app.env' ) == 'demo' ) { return null ; } $ uploaded_file_name = null ; if ( $ request -> hasFile ( $ file_name ) && $ request -> file ( $ file_name ) -> isValid ( ) ) { if ( $ file_type == 'image' ) { if ( strpos ( $ request -> $ file_name -> getClientMimeType ( ) , 'image/' ) === false ) { throw new \ Exception ( " Invalid image file " ) ; } } if ( $ request -> $ file_name -> getSize ( ) <= config ( 'constants.document_size_limit' ) ) { $ new_file_name = time ( ) . '_' . $ request -> $ file_name -> getClientOriginalName ( ) ; if ( $ request -> $ file_name -> storeAs ( $ dir_name , $ new_file_name ) ) { $ uploaded_file_name = $ new_file_name ; } } } return $ uploaded_file_name ; }
Uploads document to the server if present in the request
 @param obj $request, string $file_name, string dir_name
Uploads document to the server if present in the request @param obj $request string $file_name string dir_name
//If app environment is demo return null //Check if mime type is image