quanwei
2025-12-09 ca425b889f3c1b5847ffc26a0229307f7f8ef43e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
 
namespace app\common\model\plus\table;
 
use app\common\model\BaseModel;
 
/**
 * 万能表单模型
 */
class Record extends BaseModel
{
    protected $name = 'table_record';
    protected $pk = 'table_record_id';
 
    /**
     * 关联表单
     */
    public function tableM()
    {
        return $this->belongsTo('app\\common\\model\\plus\\table\\Table', 'table_id', 'table_id');
    }
 
    /**
     * 关联表单
     */
    public function user()
    {
        return $this->belongsTo('app\\common\\model\\user\\User', 'user_id', 'user_id');
    }
 
    /**
     * 获取详情
     */
    public static function detail($table_record_id)
    {
        return (new static())->with(['tableM'])->find($table_record_id);
    }
 
    /**
     * 获取用户最新表单记录id
     */
    public static function getLastRecordId($user_id, $call_index)
    {
        $res = (new static())->where('user_id', $user_id)
            ->where('call_index', $call_index)
            ->order('table_record_id', 'desc')
            ->limit(1)
            ->select()
            ->toArray();
        return $res ? $res[0]['table_record_id'] : 0;
    }
}