|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* @link https://github.com/yiimaker/yii2-newsletter |
|
4
|
|
|
* @copyright Copyright (c) 2017 Yii Maker |
|
5
|
|
|
* @license BSD 3-Clause License |
|
6
|
|
|
*/ |
|
7
|
|
|
|
|
8
|
|
|
namespace ymaker\newsletter\common\models\entities; |
|
9
|
|
|
|
|
10
|
|
|
use Yii; |
|
11
|
|
|
use yii\behaviors\TimestampBehavior; |
|
12
|
|
|
use yii\db\ActiveRecord; |
|
13
|
|
|
|
|
14
|
|
|
/** |
|
15
|
|
|
* This is the model class for table "{{%newsletter_client}}". |
|
16
|
|
|
* |
|
17
|
|
|
* @property int $id |
|
18
|
|
|
* @property string $contacts |
|
19
|
|
|
* @property int $created_at |
|
20
|
|
|
* @property int $updated_at |
|
21
|
|
|
* |
|
22
|
|
|
* @author Vladimir Kuprienko <[email protected]> |
|
23
|
|
|
* @since 1.0 |
|
24
|
|
|
*/ |
|
25
|
|
|
class NewsletterClient extends ActiveRecord |
|
26
|
|
|
{ |
|
27
|
|
|
const SCENARIO_CONTACTS_EMAIL = 'contactsEmail'; |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* @inheritdoc |
|
31
|
|
|
*/ |
|
32
|
|
|
public static function tableName() |
|
33
|
|
|
{ |
|
34
|
|
|
return '{{%newsletter_client}}'; |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* @inheritdoc |
|
39
|
|
|
*/ |
|
40
|
|
|
public function behaviors() |
|
41
|
|
|
{ |
|
42
|
|
|
return [ |
|
43
|
|
|
'timestamp' => TimestampBehavior::class, |
|
44
|
|
|
]; |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* @inheritdoc |
|
49
|
|
|
*/ |
|
50
|
|
|
public function rules() |
|
51
|
|
|
{ |
|
52
|
|
|
return [ |
|
53
|
|
|
['contacts', 'required'], |
|
54
|
|
|
['contacts', 'string', 'max' => 255], |
|
55
|
|
|
['contacts', 'email', 'on' => self::SCENARIO_CONTACTS_EMAIL], |
|
56
|
|
|
|
|
57
|
|
|
[['created_at', 'updated_at'], 'safe'], |
|
58
|
|
|
]; |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* @inheritdoc |
|
63
|
|
|
*/ |
|
64
|
|
|
public function attributeLabels() |
|
65
|
|
|
{ |
|
66
|
|
|
return [ |
|
67
|
|
|
'id' => Yii::t('newsletter/entity', 'ID'), |
|
68
|
|
|
'contacts' => Yii::t('newsletter/entity', 'Contacts'), |
|
69
|
|
|
'created_at' => Yii::t('newsletter/entity', 'Created at'), |
|
70
|
|
|
'updated_at' => Yii::t('newsletter/entity', 'Updated at'), |
|
71
|
|
|
]; |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
/** |
|
75
|
|
|
* @inheritdoc |
|
76
|
|
|
*/ |
|
77
|
|
|
public function transactions() |
|
78
|
|
|
{ |
|
79
|
|
|
return [ |
|
80
|
|
|
self::SCENARIO_DEFAULT => self::OP_ALL, |
|
81
|
|
|
self::SCENARIO_CONTACTS_EMAIL => self::OP_ALL, |
|
82
|
|
|
]; |
|
83
|
|
|
} |
|
84
|
|
|
} |
|
85
|
|
|
|