public function changeStatus(Request $request)
    {
        $applyStatusToChildren = $request->request->get('apply_to_children', []);
        $records = RecordsRequest::fromRequest($this->app, $request, false, [\ACL::CHGSTATUS]);
        $updated = [];
        $postStatus = (array) $request->request->get('status');

        foreach ($records as $record) {
            $sbasId = $record->getDataboxId();

            //update record
            if (null !== $updatedStatus = $this->updateRecordStatus($record, $postStatus)) {
                $updated[$record->getId()] = $updatedStatus;
            }

            //update children if current record is a story
            if (isset($applyStatusToChildren[$sbasId]) && $record->isStory()) {
                foreach ($record->getChildren() as $child) {
                    if (null !== $updatedStatus = $this->updateRecordStatus($child, $postStatus)) {
                        $updated[$record->getId()] = $updatedStatus;
                    }
                }
            }
        }

        return $this->app->json(['success' => true, 'updated' => $updated], 201);
    }
public function changeStatus(Request $request)
    {
        $applyStatusToChildren = $request->request->get('apply_to_children', []);
        $records = RecordsRequest::fromRequest($this->app, $request, false, [\ACL::CHGSTATUS]);
        $updated = [];
        $postStatus = (array) $request->request->get('status');

        foreach ($records as $record) {
            $sbasId = $record->getDataboxId();

            //update record
            if (null !== $updatedStatus = $this->updateRecordStatus($record, $postStatus)) {
                $updated[$record->getId()] = $updatedStatus;
            }

            //update children if current record is a story
            if (isset($applyStatusToChildren[$sbasId]) && $record->isStory()) {
                foreach ($record->getChildren() as $child) {
                    if (null !== $updatedStatus = $this->updateRecordStatus($child, $postStatus)) {
                        $updated[$record->getId()] = $updatedStatus;
                    }
                }
            }
        }

        return $this->app->json(['success' => true, 'updated' => $updated], 201);
    }
public function changeStatus ( Request $ request ) { $ applyStatusToChildren = $ request -> request -> get ( 'apply_to_children' , [ ] ) ; $ records = RecordsRequest :: fromRequest ( $ this -> app , $ request , false , [ \ ACL :: CHGSTATUS ] ) ; $ updated = [ ] ; $ postStatus = ( array ) $ request -> request -> get ( 'status' ) ; foreach ( $ records as $ record ) { $ sbasId = $ record -> getDataboxId ( ) ; //update record if ( null !== $ updatedStatus = $ this -> updateRecordStatus ( $ record , $ postStatus ) ) { $ updated [ $ record -> getId ( ) ] = $ updatedStatus ; } //update children if current record is a story if ( isset ( $ applyStatusToChildren [ $ sbasId ] ) && $ record -> isStory ( ) ) { foreach ( $ record -> getChildren ( ) as $ child ) { if ( null !== $ updatedStatus = $ this -> updateRecordStatus ( $ child , $ postStatus ) ) { $ updated [ $ record -> getId ( ) ] = $ updatedStatus ; } } } } return $ this -> app -> json ( [ 'success' => true , 'updated' => $ updated ] , 201 ) ; }
Change record status

@param  Request $request
@return Response
Change record status