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.
84 lines
1.8 KiB
84 lines
1.8 KiB
<?php
|
|
namespace App\Http\Model;
|
|
|
|
class UserMessage extends BaseModel
|
|
{
|
|
//用户消息
|
|
|
|
protected $table = 'user_message';
|
|
public $timestamps = false;
|
|
|
|
/**
|
|
* 不能被批量赋值的属性
|
|
*
|
|
* @var array
|
|
*/
|
|
protected $guarded = array();
|
|
|
|
//获取列表
|
|
public static function getList(array $param)
|
|
{
|
|
extract($param); //参数:limit,offset
|
|
|
|
$limit = isset($limit) ? $limit : 10;
|
|
$offset = isset($offset) ? $offset : 0;
|
|
|
|
$model = new self;
|
|
|
|
if(isset($type)){$where['type'] = $type;}
|
|
if(isset($status)){$where['status'] = $status;}
|
|
|
|
$model = $model->whereIn('user_id',array(0,$user_id));
|
|
if(isset($where)){$model = $model->where($where);}
|
|
|
|
$res['count'] = $model->count();
|
|
$res['list'] = array();
|
|
|
|
if($res['count']>0)
|
|
{
|
|
$res['list'] = $model->skip($offset)->take($limit)->orderBy('id','desc')->get();
|
|
}
|
|
else
|
|
{
|
|
return false;
|
|
}
|
|
|
|
return $res;
|
|
}
|
|
|
|
public static function getOne($where)
|
|
{
|
|
return self::where($where)->first();
|
|
}
|
|
|
|
public static function add(array $data)
|
|
{
|
|
if ($id = self::insertGetId($data))
|
|
{
|
|
return $id;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
public static function modify($where, array $data)
|
|
{
|
|
if (self::where($where)->update($data))
|
|
{
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
//删除一条记录
|
|
public static function remove($id)
|
|
{
|
|
if (!self::whereIn('id', explode(',', $id))->delete())
|
|
{
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
}
|