<?php

namespace Modules\Approval\Support;

class ApprovalRelations
{
    public static function approvalRequest(): array
    {
        return [
            'approvalRequest' => function ($query) {
                $query->select([
                    'id',
                    'approvable_type',
                    'approvable_id',
                    'approval_workflow_id',
                    'status',
                    'current_level',
                    'submitted_at',
                    'submitted_by',
                ])->with([
                    'workflow:id,code,name',
                    'submitter:id,name,sign',
                    'steps' => function ($stepQuery) {
                        $stepQuery->with([
                            'workflowStep:id,role_id',
                            'workflowStep.role:id,title',
                            'actor:id,name,sign',
                        ]);
                    },
                ]);
            },
        ];
    }
}
