[refactor model] complete refactoring of the model.php