3f2bc3d0
Administrator
first commit
|
1
2
3
4
5
6
7
|
<?php
namespace common\models;
use Yii;
/**
|
90a6ed1a
Administrator
basket
|
8
|
* This is the model class for table "page".
|
3f2bc3d0
Administrator
first commit
|
9
10
|
*
* @property integer $id
|
3f2bc3d0
Administrator
first commit
|
11
12
13
14
|
* @property string $translit
* @property string $title
* @property string $body
* @property string $meta_title
|
90a6ed1a
Administrator
basket
|
15
16
|
* @property string $meta_keywords
* @property string $meta_description
|
3f2bc3d0
Administrator
first commit
|
17
|
* @property string $seo_text
|
90a6ed1a
Administrator
basket
|
18
|
* @property string $h1
|
3f2bc3d0
Administrator
first commit
|
19
20
21
22
23
24
25
26
|
*/
class Page extends \yii\db\ActiveRecord
{
/**
* @inheritdoc
*/
public static function tableName()
{
|
90a6ed1a
Administrator
basket
|
27
|
return 'page';
|
3f2bc3d0
Administrator
first commit
|
28
|
}
|
3f2bc3d0
Administrator
first commit
|
29
30
31
|
/**
* @inheritdoc
*/
|
90a6ed1a
Administrator
basket
|
32
|
public function behaviors()
|
3f2bc3d0
Administrator
first commit
|
33
34
|
{
return [
|
90a6ed1a
Administrator
basket
|
35
36
37
38
39
40
|
'slug' => [
'class' => 'common\behaviors\Slug',
'in_attribute' => 'title',
'out_attribute' => 'translit',
'translit' => true
]
|
3f2bc3d0
Administrator
first commit
|
41
42
|
];
}
|
3f2bc3d0
Administrator
first commit
|
43
44
45
|
/**
* @inheritdoc
*/
|
90a6ed1a
Administrator
basket
|
46
|
public function rules()
|
3f2bc3d0
Administrator
first commit
|
47
48
|
{
return [
|
90a6ed1a
Administrator
basket
|
49
50
|
[['body', 'seo_text'], 'string'],
[['translit', 'title', 'meta_title', 'meta_keywords', 'meta_description', 'h1'], 'string', 'max' => 255],
|
3f2bc3d0
Administrator
first commit
|
51
52
|
];
}
|
3f2bc3d0
Administrator
first commit
|
53
54
|
public function getPageTranslit($page){
return self::find()
|
90a6ed1a
Administrator
basket
|
55
|
->where(['translit' => $page])
|
3f2bc3d0
Administrator
first commit
|
56
57
58
|
->one();
}
|
90a6ed1a
Administrator
basket
|
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'id' => 'ID',
'translit' => 'Translit',
'title' => 'Title',
'body' => 'Body',
'meta_title' => 'Meta Title',
'meta_keywords' => 'Meta Keywords',
'meta_description' => 'Meta Description',
'seo_text' => 'Seo Text',
'h1' => 'H1',
];
}
|
3f2bc3d0
Administrator
first commit
|
76
|
}
|