62 lines
1.3 KiB
PHP
62 lines
1.3 KiB
PHP
<?php
|
|
|
|
/**
|
|
* @author Any
|
|
* @description KISS
|
|
* @date 2020-11-5
|
|
* @version 1.0.0
|
|
*
|
|
* _____LOG_____
|
|
*
|
|
*/
|
|
namespace app\modules\admin\models\comment;
|
|
use app\components\EncryptHelper;
|
|
use app\models\Comment;
|
|
use app\models\Model;
|
|
use app\modules\admin\models\AdminModel;
|
|
use yii\data\Pagination;
|
|
class CommentActionForm extends AdminModel
|
|
{
|
|
public $ids;
|
|
public function rules()
|
|
{
|
|
return [
|
|
[['ids'], 'required'],
|
|
[['ids'], 'safe'],
|
|
];
|
|
}
|
|
|
|
public function attributeLabels()
|
|
{
|
|
return [
|
|
'ids' => '选择项',
|
|
];
|
|
}
|
|
|
|
public function delete()
|
|
{
|
|
if(!$this->validate()){
|
|
return $this->getModelError();
|
|
}
|
|
|
|
foreach ($this->ids as $item){
|
|
$model = Comment::findOne(['id' => $item,'is_delete' => 0]);
|
|
if($model == null){
|
|
return Model::asReturnError('该评论不存在或已被清理');
|
|
}
|
|
if($model->is_delete == 1){
|
|
continue;
|
|
}
|
|
$model->is_delete = 1;
|
|
$model->deleted_at = time();
|
|
if(!$model->save()){
|
|
return Model::getModelErrorInfo($model);
|
|
}
|
|
}
|
|
|
|
return Model::asReturnSuccess('操作成功');
|
|
}
|
|
|
|
|
|
|
|
} |