'array', // 自动转换 JSON 字段为数组 'finished_at' => 'datetime', 'deadline_at' => 'datetime', 'created_at' => 'datetime', 'updated_at' => 'datetime', ]; public function records() { return $this->hasMany(ApprovalRecords::class, 'instance_id', 'id'); } public function flows() { return $this->belongsTo(ApprovalFlows::class, 'flow_type', 'type'); } public function initiator() { return $this->belongsTo(User::class, 'initiator_id', 'id'); } public function bizInfo() { return $this->belongsTo(StockOrders::class, 'biz_id', 'id'); } /** * 获取当前步骤的所有审批记录(pending 状态) */ public function currentStepRecords() { return $this->approvalRecords() ->where('step_index', $this->current_step) ->where('status', 'pending'); } }