<?php
    
    namespace common\models;
    
    use artbox\core\models\Feedback as FeedbackCore;
    /**
     * Created by PhpStorm.
     * User: timur
     * Date: 29.11.17
     * Time: 14:48
     *
     * @property $subject
     */
    class Feedback extends FeedbackCore
    {
    
        public function scenarios()
        {
            $scenarios = parent::scenarios();
            $scenarios = array_merge(
                $scenarios,
                [
                    self::SCENARIO_FEEDBACK => [
                        'name',
                        'email',
                        'message',
                        'returnUrl',
                        'subject'
                    ],
                    self::SCENARIO_CALLBACK => [
                        'name',
                        'phone',
                        'message',
                        'returnUrl',
                        'subject'
                    ],
                ]
            );
            return $scenarios;
        }
    
        public function rules()
        {
            return [
                [
                    [
                        'name',
                        'email',
                        'phone',
                    ],
                    'required',
                    'on' => self::SCENARIO_DEFAULT,
                ],
                [
                    [
                        'name',
                        'email',
                    ],
                    'required',
                    'on' => self::SCENARIO_FEEDBACK,
                ],
                [
                    [
                        'phone',
                        'name',
                    ],
                    'required',
                    'on' => self::SCENARIO_CALLBACK,
                ],
                [
                    [ 'email' ],
                    'email',
                ],
                //                [
                //                    [ 'phone' ],
                //                    'match',
                //                    'pattern' => '/^\+38\(\d{3}\)\d{3}-\d{2}-\d{2}$/',
                //                ],
                [
                    [
                        'name',
                        'phone',
                        'email',
                        'subject',
                    ],
                    'string',
                    'max' => 255,
                ],
                [
                    [
                        'message',
                    ],
                    'string',
                ],
                [
                    [
                        'status',
                    ],
                    'boolean',
                ],
                [
                    'returnUrl',
                    'safe',
                ],
            ];
        }
        
        public function attributeLabels()
        {
            return array_merge(
                parent::attributeLabels(),
                [
                    'subject' => \Yii::t('app', 'subject'),
                ]
            );
        }
    
    }