You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
75 lines
1.3 KiB
75 lines
1.3 KiB
6 years ago
|
<?php
|
||
|
|
||
|
namespace common\modules\forms\entities;
|
||
|
|
||
|
use yii\behaviors\TimestampBehavior;
|
||
|
use yii\db\ActiveRecord;
|
||
|
use Yii;
|
||
|
|
||
|
/**
|
||
|
* @property int $id
|
||
|
* @property int $form_id
|
||
|
* @property string $data
|
||
|
* @property int $new
|
||
|
* @property int $created_at
|
||
|
* @property int $updated_at
|
||
|
*
|
||
|
* @property Form $form
|
||
|
*
|
||
|
*/
|
||
|
class FormMessage extends ActiveRecord
|
||
|
{
|
||
|
const STATUS_ACTIVE = 1;
|
||
|
const STATUS_DRAFT = 0;
|
||
|
|
||
|
public static function create(
|
||
|
$form_id,
|
||
|
$data
|
||
|
): self
|
||
|
{
|
||
|
$message = new static();
|
||
|
$message->form_id = $form_id;
|
||
|
$message->data = $data;
|
||
|
return $message;
|
||
|
}
|
||
|
|
||
|
public function edit(
|
||
|
$form_id,
|
||
|
$data
|
||
|
): void
|
||
|
{
|
||
|
$this->form_id = $form_id;
|
||
|
$this->data = $data;
|
||
|
}
|
||
|
|
||
|
public static function tableName(): string
|
||
|
{
|
||
|
return '{{%forms_messages}}';
|
||
|
}
|
||
|
|
||
|
public function behaviors(): array
|
||
|
{
|
||
|
return [
|
||
|
TimestampBehavior::class,
|
||
|
];
|
||
|
}
|
||
|
|
||
|
public function transactions(): array
|
||
|
{
|
||
|
return [
|
||
|
self::SCENARIO_DEFAULT => self::OP_ALL,
|
||
|
];
|
||
|
}
|
||
|
|
||
|
public function attributeLabels() {
|
||
|
return [
|
||
|
'form_id' => Yii::t('form', 'Form'),
|
||
|
'data' => Yii::t('form', 'Form Data'),
|
||
|
];
|
||
|
}
|
||
|
|
||
|
public function getForm()
|
||
|
{
|
||
|
return $this->hasOne(Form::class, ['id' => 'form_id']);
|
||
|
}
|
||
|
}
|