app/Api/V1/Controllers/DocumentController.php
/**
     * Upload a new document
     *
     * @param Request $request
     * @param DocumentFormat $documentFormat
     * @return Response
     * @throws \Illuminate\Validation\ValidationException
     */
Upload a new document
@param Request $request
@param DocumentFormat $documentFormat
@return Response
@throws \Illuminate\Validation\ValidationException
Upload a new document @param Request $request @param DocumentFormat $documentFormat @return Response @throws \ Illuminate \ Validation \ ValidationException
public function store(Request $request, DocumentFormat $documentFormat)
    { 
        $allowedFormats = $documentFormat->allowedExtensionsToCommaSeperatedString();
        $rules = [
            'file' => 'required|max:2048|mimes:' . $allowedFormats,
            'document_type' => 'required',
        ];
        $message = [
            'mimes' => 'uploaded document format, not allowed'
        ];
        $this->validate($request, $rules, $message);
        $document = Document::getDocument($request);
        if ($documents = Document::saveDocument($document, null, $request->document_type)) {
            return new Response($documents, 201);
        }
        throw new StoreResourceFailedException('Couldn\'t upload document');
    }
public function store ( Request $ request , DocumentFormat $ documentFormat ) { $ allowedFormats = $ documentFormat -> allowedExtensionsToCommaSeperatedString ( ) ; $ rules = [ 'file' => 'required|max:2048|mimes:' . $ allowedFormats , 'document_type' => 'required' , ] ; $ message = [ 'mimes' => 'uploaded document format, not allowed' ] ; $ this -> validate ( $ request , $ rules , $ message ) ; $ document = Document :: getDocument ( $ request ) ; if ( $ documents = Document :: saveDocument ( $ document , null , $ request -> document_type ) ) { return new Response ( $ documents , 201 ) ; } throw new StoreResourceFailedException ( 'Couldn\'t upload document' ) ; }
Upload a new document
 @param Request $request
 @param DocumentFormat $documentFormat
 @return Response
 @throws \Illuminate\Validation\ValidationException
Upload a new document @param Request $request @param DocumentFormat $documentFormat @return Response @throws \ Illuminate \ Validation \ ValidationException
//get allowed formats //validate