123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- <?php
- namespace app\user\model;
- use think\Model;
- class Mail extends Model{
-
- protected $autoWriteTimestamp = 'datetime'; // 开启自动写入时间戳字段
- protected $createTime = 'create_time'; // 创建时间
- protected $updateTime = ''; // 每次更新时间
-
- public function initialize(){
- parent::initialize();
- }
-
- /**
- * 获取数据信息
- * @param int $page 页码
- * @param array $where 查询条件
- */
- public function getInfo($page = 0, $where = array()){
- return $this->db()
- ->where($where)
- ->page($page, config('paginate.list_rows'))
- ->select();
- }
-
- /**
- * 获取分页信息
- * @param array $where 查询条件
- */
- public function getPage($where = array()){
- $query = getPaginatiorQuery();
- $total = $this->db()->where($where)->count();
- // 查询条件
- $config = ['query'=>$query];
- $paginate = $this->db()->where($where)->paginate(config('paginate.list_rows'), $total, $config);
-
- return $paginate->render();
- }
-
- /**
- * 根据id找到对象
- * @param int $id
- */
- public function getMailById($id){
- return $this->db()->where(['id'=>$id])->find();
- }
-
- /**
- * 添加和更新的方法
- */
- public function addAndSave(){
- $data = request()->post();
- return $this->allowField(true)->isUpdate(isset($data['id']) && $data['id']?true:false)->save($data);
- }
-
- /**
- * 没有发送的邮件
- * @return number|string
- */
- public function notSendMail(){
- return $this->db()->where(['is_send'=>0])->count();
- }
-
- }
|