0], [['goal_type'], 'string', 'max' => 32], [['title'], 'string', 'max' => 190], [['image_path'], 'string', 'max' => 255], [['currency'], 'string', 'max' => 8], [['goal_type'], 'in', 'range' => array_keys(self::goalTypeOptions())], ]; } public static function goalTypeOptions(): array { return [ self::TYPE_RESCUE_GENERAL => Yii::t('DonationsModule.base', 'Rescue General'), self::TYPE_ANIMAL => Yii::t('DonationsModule.base', 'Animal'), self::TYPE_NEED => Yii::t('DonationsModule.base', 'Need Specific'), self::TYPE_SPECIAL_NEED => Yii::t('DonationsModule.base', 'Special Need'), self::TYPE_SPONSORSHIP => Yii::t('DonationsModule.base', 'Sponsorship'), ]; } public function beforeSave($insert) { if (!parent::beforeSave($insert)) { return false; } $now = date('Y-m-d H:i:s'); if ($insert && empty($this->created_at)) { $this->created_at = $now; } $this->updated_at = $now; if (empty($this->currency)) { $this->currency = 'USD'; } if ($this->is_active === null) { $this->is_active = 1; } return true; } }