init
This commit is contained in:
49
app/common/model/Pinglun.php
Executable file
49
app/common/model/Pinglun.php
Executable file
@@ -0,0 +1,49 @@
|
||||
<?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;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user