<?php
namespace app\service\model;

use think\Model;

/**
 * 工单模型
 */
class ServiceLog extends Model
{


    /**
     * 数据筛选
     *
     * @access public
     * @param mixed $field 字段
     * @param mixed $where 条件
     * @param mixed $join 关联
     * @param mixed $offset 分页开始
     * @param mixed $limit 分页大小
     * @return array 返回类型
     */
    public function selectServiceLog($field, $offset, $limit, $where=[], $join=[])
    {
        $result = $this->field($field);
        if (empty($join) === false) {
            $result = $result->alias('a');
            foreach ($join as $k => $v) {
                $result = $result->join($k, $v);
            }
        }

        if (empty($where) === false) {
            $result = $result->where($where);
        }

        $result = $result->limit($offset, $limit)->order('start_time', 'desc')->select();
        return $result;

    }//end selectServiceLog()


    /**
     * 数据总数
     *
     * @access public
     * @param mixed $where 条件
     * @return array 返回类型
     */
    public function countServiceLog($where=[])
    {
        $result = $this;

        if (empty($where) === false) {
            $result = $result->where($where);
        }

        $result = $result->count();
        return $result;

    }//end countServiceLog()


}
