use yii\base\Model; class User extends Model { public $username; public $email; public function __construct() { $this->username = "JohnDoe"; $this->email = "johndoe@example.com"; } }
use yii\base\Model; class ContactForm extends Model { public $name; public $email; public $subject; public $body; public function __construct($config = []) { parent::__construct($config); $this->subject = "Contact Form Submission"; } }In this example, we are creating a new ContactForm model that also extends the Yii Model class. The __construct method of the ContactForm class sets a default value for the subject property, which is "Contact Form Submission". The $config parameter allows us to pass in additional configuration options to the model. Overall, the yii\base\Model __construct method is an essential part of the Yii Framework's model system, allowing developers to set default values and configure models in a flexible and streamlined way.