d1f8bd40
Alexey Boroda
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
<?php
namespace frontend\modules\faq\models;
use yii\helpers\HtmlPurifier;
/**
* Class Question
*
* @package frontend\modules\faq\models
* @author FilamentV <vortex.filament@gmail.com>
* @copyright (c), Thread
*/
class Question extends \thread\modules\faq\models\Question
{
/**
* @return array
*/
public function scenarios()
{
return [
'add_syq' => ['group_id', 'user_name', 'question', 'email'],
];
}
/**
* @return \yii\db\ActiveQuery
*/
public function getGroup()
{
return $this->hasOne(Group::class, ['id' => 'group_id']);
}
/**
* @param bool $insert
* @return bool
*/
public function beforeSave($insert)
{
$this->HtmlPurifier(['user_name', 'question']);
return parent::beforeSave($insert);
}
/**
* @param array $attributes
*/
public function HtmlPurifier(array $attributes)
{
foreach ($attributes as $attribute) {
$this->{$attribute} = HtmlPurifier::process($this->{$attribute});
}
}
}
|