50 lines
1.2 KiB
PHP
Executable File
50 lines
1.2 KiB
PHP
Executable File
<?php
|
|
|
|
namespace app\common\model;
|
|
|
|
use think\Model;
|
|
use think\Request;
|
|
use think\Config;
|
|
|
|
class Pinglun extends Model {
|
|
|
|
use \app\common\traits\IndexModel;
|
|
|
|
protected $auto = ['content'];
|
|
protected $insert = ['stat' => 0, 'display' => 0, 'ip'];
|
|
|
|
public function insertRow($data) {
|
|
$object = $this::create($data);
|
|
return $object;
|
|
}
|
|
|
|
protected function setContentAttr($value) {
|
|
return htmlspecialchars($value);
|
|
}
|
|
|
|
protected function setIpAttr() {
|
|
return Request::instance()->ip();
|
|
}
|
|
|
|
public function getCommentList($where = null, $order = null, $field = null, $limit = null) {
|
|
if (is_array($where)) {
|
|
$where = array_merge(['stat' => ['eq', '0']], $where);
|
|
}
|
|
if ($where) {
|
|
$this->where($where);
|
|
}
|
|
if ($order) {
|
|
$this->order($order);
|
|
}
|
|
if ($field) {
|
|
$this->field($field);
|
|
}
|
|
if (empty($limit)) {
|
|
$limit = Config::get('list_rows') > 0 ? Config::get('list_rows') : 12;
|
|
}
|
|
$object = $this->paginate($limit);
|
|
return $object;
|
|
}
|
|
|
|
}
|