Yii Models

Models are part of MVC structure. They represent the rules and logic for an application. Means they hold data and define the validating rules for the data.

Model classes are extended by yii\base\Model or its child classes.

Mainly following features are implemented using models.

  • attribute declaration
  • attribute labels
  • massive attribute assignment
  • scenario-based validation
  • can not embed HTML
  • can not be directly accessed

# Attributes

Attributes mainly represent the business data. Each attribute is a publicly accessible property of a model. They can be accessed like array elements or normal object properties. it is like publicly accessible properties of a model.

The method,