public function post()
    {
        $request = $this->getDI()->get('request');
        // supply everything the request object could possibly need to fulfill the request
        $post = $request->getJson($this->getControllerName('singular'), $this->getModel());

        if (!$post) {
            throw new HTTPException('There was an error adding new record.  Missing POST data.', 400, [
                'dev' => 'Invalid data posted to the server',
                'code' => '568136818916816555'
            ]);
        }

        if(method_exists($this->model, "getBlockColumns")) {
            // filter out any block columns from the posted data
            $blockFields = $this->model->getBlockColumns();
            foreach ($blockFields as $key => $value) {
                unset($post->$value);
            }
        }

        $post = $this->beforeSave($post);
        // This record only must be created
        $id = $this->entity->save($post);
        $this->afterSave($post, $id);

        // now fetch the record so we can return it
        $result = $this->entity->findFirst($id);

        if ($result->countResults() == 0) {
            // This is bad. Throw a 500. Responses should always be objects.
            throw new HTTPException('There was an error retrieving the newly created record.', 500, [
                'dev' => 'The resource you requested is not available after it was just created',
                'code' => '1238510381861'
            ]);
        } else {
            return $result;
        }
    }
public function post()
    {
        $request = $this->getDI()->get('request');
        // supply everything the request object could possibly need to fulfill the request
        $post = $request->getJson($this->getControllerName('singular'), $this->getModel());

        if (!$post) {
            throw new HTTPException('There was an error adding new record.  Missing POST data.', 400, [
                'dev' => 'Invalid data posted to the server',
                'code' => '568136818916816555'
            ]);
        }

        if(method_exists($this->model, "getBlockColumns")) {
            // filter out any block columns from the posted data
            $blockFields = $this->model->getBlockColumns();
            foreach ($blockFields as $key => $value) {
                unset($post->$value);
            }
        }

        $post = $this->beforeSave($post);
        // This record only must be created
        $id = $this->entity->save($post);
        $this->afterSave($post, $id);

        // now fetch the record so we can return it
        $result = $this->entity->findFirst($id);

        if ($result->countResults() == 0) {
            // This is bad. Throw a 500. Responses should always be objects.
            throw new HTTPException('There was an error retrieving the newly created record.', 500, [
                'dev' => 'The resource you requested is not available after it was just created',
                'code' => '1238510381861'
            ]);
        } else {
            return $result;
        }
    }
public function post ( ) { $ request = $ this -> getDI ( ) -> get ( 'request' ) ; // supply everything the request object could possibly need to fulfill the request $ post = $ request -> getJson ( $ this -> getControllerName ( 'singular' ) , $ this -> getModel ( ) ) ; if ( ! $ post ) { throw new HTTPException ( 'There was an error adding new record.  Missing POST data.' , 400 , [ 'dev' => 'Invalid data posted to the server' , 'code' => '568136818916816555' ] ) ; } if ( method_exists ( $ this -> model , "getBlockColumns" ) ) { // filter out any block columns from the posted data $ blockFields = $ this -> model -> getBlockColumns ( ) ; foreach ( $ blockFields as $ key => $ value ) { unset ( $ post -> $ value ) ; } } $ post = $ this -> beforeSave ( $ post ) ; // This record only must be created $ id = $ this -> entity -> save ( $ post ) ; $ this -> afterSave ( $ post , $ id ) ; // now fetch the record so we can return it $ result = $ this -> entity -> findFirst ( $ id ) ; if ( $ result -> countResults ( ) == 0 ) { // This is bad. Throw a 500. Responses should always be objects. throw new HTTPException ( 'There was an error retrieving the newly created record.' , 500 , [ 'dev' => 'The resource you requested is not available after it was just created' , 'code' => '1238510381861' ] ) ; } else { return $ result ; } }
Attempt to save a record from POST
This should be saving a new record

@throws HTTPException
@return mixed return valid Apache code, could be an error, maybe not
@throws HTTPException
Attempt to save a record from POST This should be saving a new record