app/Api/V1/Controllers/DocumentTypeController.php
/**
     * create new document type
     *
     * @param Request $request
     * @return DocumentType
     */
create new document type
@param Request $request
@return DocumentType
create new document type @param Request $request @return DocumentType
public function store(Request $request)
    {
        $this->validate($request, [
            'name' => 'required|string|unique:document_types,name',
            'description' => 'string|nullable'
        ], ['name.unique' => 'Document type already exists']);
        $data = $request->only('name', 'description');
        $documentType = new DocumentType($data);
        if ($documentType->save()) {
            return $documentType;
        }
        throw new StoreResourceFailedException('Document type couldn\'t be stored');
    }
public function store ( Request $ request ) { $ this -> validate ( $ request , [ 'name' => 'required|string|unique:document_types,name' , 'description' => 'string|nullable' ] , [ 'name.unique' => 'Document type already exists' ] ) ; $ data = $ request -> only ( 'name' , 'description' ) ; $ documentType = new DocumentType ( $ data ) ; if ( $ documentType -> save ( ) ) { return $ documentType ; } throw new StoreResourceFailedException ( 'Document type couldn\'t be stored' ) ; }
create new document type
 @param Request $request
 @return DocumentType
create new document type @param Request $request @return DocumentType