public function changeType(Request $request)
    {
        $typeLst = $request->request->get('types', []);
        $records = RecordsRequest::fromRequest($this->app, $request, false, [\ACL::CANMODIFRECORD]);
        $mimeLst = $request->request->get('mimes', []);
        $forceType = $request->request->get('force_types', '');
        $updated = [];

        foreach ($records as $record) {
            try {
                $recordType = !empty($forceType) ? $forceType : (isset($typeLst[$record->getId()]) ? $typeLst[$record->getId()] : null);
                $mimeType = isset($mimeLst[$record->getId()]) ? $mimeLst[$record->getId()] : null;

                if ($recordType) {
                    $record->setType($recordType);
                    $updated[$record->getId()]['record_type'] = $recordType;
                }

                if ($mimeType) {
                    $record->setMimeType($mimeType);
                    $updated[$record->getId()]['mime_type'] = $mimeType;
                }
            } catch (\Exception $e) {

            }
        }

        return $this->app->json(['success' => true, 'updated' => $updated], 201);
    }
public function changeType(Request $request)
    {
        $typeLst = $request->request->get('types', []);
        $records = RecordsRequest::fromRequest($this->app, $request, false, [\ACL::CANMODIFRECORD]);
        $mimeLst = $request->request->get('mimes', []);
        $forceType = $request->request->get('force_types', '');
        $updated = [];

        foreach ($records as $record) {
            try {
                $recordType = !empty($forceType) ? $forceType : (isset($typeLst[$record->getId()]) ? $typeLst[$record->getId()] : null);
                $mimeType = isset($mimeLst[$record->getId()]) ? $mimeLst[$record->getId()] : null;

                if ($recordType) {
                    $record->setType($recordType);
                    $updated[$record->getId()]['record_type'] = $recordType;
                }

                if ($mimeType) {
                    $record->setMimeType($mimeType);
                    $updated[$record->getId()]['mime_type'] = $mimeType;
                }
            } catch (\Exception $e) {

            }
        }

        return $this->app->json(['success' => true, 'updated' => $updated], 201);
    }
public function changeType ( Request $ request ) { $ typeLst = $ request -> request -> get ( 'types' , [ ] ) ; $ records = RecordsRequest :: fromRequest ( $ this -> app , $ request , false , [ \ ACL :: CANMODIFRECORD ] ) ; $ mimeLst = $ request -> request -> get ( 'mimes' , [ ] ) ; $ forceType = $ request -> request -> get ( 'force_types' , '' ) ; $ updated = [ ] ; foreach ( $ records as $ record ) { try { $ recordType = ! empty ( $ forceType ) ? $ forceType : ( isset ( $ typeLst [ $ record -> getId ( ) ] ) ? $ typeLst [ $ record -> getId ( ) ] : null ) ; $ mimeType = isset ( $ mimeLst [ $ record -> getId ( ) ] ) ? $ mimeLst [ $ record -> getId ( ) ] : null ; if ( $ recordType ) { $ record -> setType ( $ recordType ) ; $ updated [ $ record -> getId ( ) ] [ 'record_type' ] = $ recordType ; } if ( $ mimeType ) { $ record -> setMimeType ( $ mimeType ) ; $ updated [ $ record -> getId ( ) ] [ 'mime_type' ] = $ mimeType ; } } catch ( \ Exception $ e ) { } } return $ this -> app -> json ( [ 'success' => true , 'updated' => $ updated ] , 201 ) ; }
Change record type

@param  Request $request
@return Response
Change record type