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; } }