Feedback.php 2.14 KB
<?php
    namespace common\models;
    /**
     * User: timur
     * Date: 31.01.18
     * Time: 10:56
     */
    
    use artbox\core\models\Feedback as ArtboxFeedback;
    use yii\helpers\VarDumper;

    /**
     * Class Feedback
     *
     * @property string $topic
     *
     * @package common\models
     */
    class Feedback extends ArtboxFeedback
    {
        
        const SCENARIO_CALCULATOR = 'calculator';
        
        public function scenarios()
        {
            return array_merge(
                parent::scenarios(),
                [
                    parent::SCENARIO_FEEDBACK => [
                        'name',
                        'email',
                        'message',
                        'returnUrl',
                        'topic',
                    ],
                    parent::SCENARIO_CALLBACK => [
                        'name',
                        'phone',
                        'message',
                        'returnUrl',
                        'topic',
                    ],
                    self::SCENARIO_CALCULATOR => [
                        'name',
                        'phone',
                        'returnUrl',
                        'topic',
                        'calc_json_info',
                        
                    ]
                ]
            );
        }
    
        public function rules()
        {
            
            return array_merge(
                parent::rules(),
                [
                    [
                        [
                            'topic',
                        ],
                        'required',
                    ],
                    [
                        [
                            'topic',
                        ],
                        'string',
                        'max' => 100,
                    ],
                    [
                        [
                            'calc_json_info'
                        ],
                        'required',
                        'on' => self::SCENARIO_CALCULATOR,
                    ]
                ]
            );
        }
        
        
    }