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.
81 lines
1.5 KiB
81 lines
1.5 KiB
<?php |
|
|
|
namespace common\modules\forms\entities; |
|
|
|
use common\modules\forms\entities\queries\FormMessageQuery; |
|
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_OLD = 0; |
|
const STATUS_NEW = 1; |
|
|
|
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']); |
|
} |
|
|
|
public static function find(): FormMessageQuery |
|
{ |
|
return new FormMessageQuery(static::class); |
|
} |
|
} |