Commit 7df57148cf4450e40dc25ce2c8841269d9be7bc3

Authored by Yarik
1 parent ed4ee1f2

test

Showing 1 changed file with 77 additions and 0 deletions   Show diff stats
common/models/Feedback.php 0 → 100644
  1 +<?php
  2 +
  3 +namespace common\models;
  4 +
  5 +use common\modules\fileloader\behaviors\FileloaderBehavior;
  6 +use Yii;
  7 +use yii\behaviors\TimestampBehavior;
  8 +use yii\db\Expression;
  9 +
  10 +/**
  11 + * This is the model class for table "feedback".
  12 + *
  13 + * @property integer $feedback_id
  14 + * @property string $name
  15 + * @property string $phone
  16 + * @property string $email
  17 + * @property string $answer
  18 + * @property string $file
  19 + * @property string $date_add
  20 + */
  21 +class Feedback extends \yii\db\ActiveRecord
  22 +{
  23 + /**
  24 + * @inheritdoc
  25 + */
  26 + public static function tableName()
  27 + {
  28 + return 'feedback';
  29 + }
  30 +
  31 + /**
  32 + * @inheritdoc
  33 + */
  34 + public function behaviors()
  35 + {
  36 + return [
  37 + [
  38 + 'class' => TimestampBehavior::className(),
  39 + 'createdAtAttribute' => 'date_add',
  40 + 'updatedAtAttribute' => false,
  41 + 'value' => new Expression('NOW()'),
  42 + ],
  43 + 'fileloader' => [
  44 + 'class' => FileloaderBehavior::className(),
  45 + ],
  46 + ];
  47 + }
  48 +
  49 + /**
  50 + * @inheritdoc
  51 + */
  52 + public function rules()
  53 + {
  54 + return [
  55 + [['name', 'answer', 'email'], 'required'],
  56 + [['email'], 'email'],
  57 + [['phone'], 'match', 'pattern' => '^\+?(?:\d{0,3})?[\(\s]?\d{0,5}[\)\s]?\d{3}[-\s]?\d{2}[-\s]?\d{2}$'],
  58 + [['name', 'phone', 'answer'], 'string', 'max' => 255],
  59 + ];
  60 + }
  61 +
  62 + /**
  63 + * @inheritdoc
  64 + */
  65 + public function attributeLabels()
  66 + {
  67 + return [
  68 + 'feedback_id' => Yii::t('app', 'Feedback ID'),
  69 + 'name' => Yii::t('app', 'Feedback name'),
  70 + 'phone' => Yii::t('app', 'Feedback phone'),
  71 + 'email' => Yii::t('app', 'Feedback email'),
  72 + 'answer' => Yii::t('app', 'Feedback answer'),
  73 + 'file' => Yii::t('app', 'Feedback file'),
  74 + 'date_add' => Yii::t('app', 'Feedback date Add'),
  75 + ];
  76 + }
  77 +}
... ...