<?php
namespace app\common\model;
use liuniu\BaseModel;

class HelpApply extends BaseModel
{
    // 表名
    protected $name = 'help_apply';

    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    protected $deleteTime = false;

    public static function lst($where)
    {
        $model = new self;
        if (isset($where['cid']) && $where['cid'] > 0) $model->where('cid', $where['cid']);
        if (isset($where['user_id']) && $where['user_id'] > 0) $model->where('user_id', $where['user_id']);
        if (isset($where['help_id']) && $where['help_id'] > 0) $model->where('help_id', $where['help_id']);
        if (isset($where['status']) && $where['status'] > -2) $model->where('status', $where['status']);
        $data = $model->order('id desc')->page($where['page'], $where['limit'])->select();
        foreach ($data as &$v)
        {
            $v['info'] = Help::info($v['cid'],$v['id'],$v['user_id']);
        }
        return $data;
    }
}