Blame view

common/models/Subscribe.php 606 Bytes
3f2bc3d0   Administrator   first commit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
  <?php

  

  namespace app\models;

  

  class Subscribe extends \yii\db\ActiveRecord

  {

      public static function tableName()

      {

          return 'subscribe';

      }

      

      public function rules()

      {

          return [

              [['email','sale'], 'required'],

              [['email'], 'email'],

              [['email'], 'is_email'],

          ];

      }

      

      public function is_email($attribute){

  		if(self::find()

  			->where('email = :email', [':email' => $this->email])

  			->exists())

              $this->addError('email','Такой email уже есть.');        

      }

      

  }