28 lines
606 B
PHP
28 lines
606 B
PHP
<?php
|
|
|
|
namespace app\models;
|
|
|
|
class CommentNewForm extends \yii\base\Model
|
|
{
|
|
public $message;
|
|
public $user_id;
|
|
public $material_id;
|
|
/**
|
|
* {@inheritDoc}
|
|
*/
|
|
public function rules() {
|
|
return [
|
|
[['message'], 'string'],
|
|
[['user_id', 'material_id'], 'integer'],
|
|
[['message', 'user_id', 'material_id'], 'required'],
|
|
];
|
|
}
|
|
|
|
public function create()
|
|
{
|
|
$comment = new Comment();
|
|
$comment->user_id = $this->user_id;
|
|
$comment->material_id = $this->material_id;
|
|
return $comment->save();
|
|
}
|
|
} |