We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Skip columns

Hello! I want to create a logic that will keep in pending specific columns from some tables and store them in a separate table (snapshots with status pending) and apply them on admin approval. When user data is submitted, unmoderated rows will be updated instantly in table while moderated rows will processed in table "snapshots" (id, table, serializeddata, status) -> if already pending, edit else insert pending data. What can I do in model to achieve this ? I was thinking for something like this "pseudocode" logic:

beforeSave() {
    if usersubmited {
        $allowed = ['name', 'email'];
        self::save($userinputdata, ['allowed', 'columns']); 
        Revisions::save(["table"=>self::getSource(), "data"=>serialize($this->toArray(['skipped_columns']), 'status'=>pending)]);
        return false;
    } 
}

But i'm not if phalcon can do this:

self::save($userinputdata, ['allowed', 'columns']);
OR
$this->toArray(['skipped_columns']),

Any advice and suggestions will be greatly appreciated :D Thanks!



6.0k

Hello, That option is skipping columns even for admin... and is not what I need.