IndicatorReviewTask
Intro
The IndicatorReviewTask model represents verification tasks assigned to verifiers in the multi-level indicator approval workflow. These tasks are automatically created by event listeners when submissions are made or approved, and serve as the entry point for the verification process.
Model and Relationships
The IndicatorReviewTask model has the following key relationships:
- Submission: Belongs-to relationship with IndicatorSubmission model
- Assigned User: Belongs-to relationship with User model (verifier_user_id) - the verifier
- Review: Has-one relationship with IndicatorSubmissionReview model (when verification is completed)
Key Fields
Assignment Fields
indicator_submission_id: Links to the submission being verifiedverifier_user_id: The verifier responsible for this reviewverification_level: Level of verification (1 or 2)status: Current review task statusassigned_at: When the task was createdcompleted_at: When verification was completed (nullable)
Status Management
Uses IndicatorReviewTaskStatusEnum for status tracking:
PENDING: Initial status when review task is createdCOMPLETED: Set when verifier completes the review (approve or reject)
Multi-Level Verification System
The system supports a two-level verification process:
Level 1 Verification
- Created automatically when
IndicatorSubmissionSubmittedevent is dispatched - Assigned to users with
verifier_1_role_idrole - Approval creates Level 2 task (if Level 2 verifiers exist) or completes workflow
- Rejection returns submission to admin for revision
Level 2 Verification
- Created when Level 1 verification is approved
- Assigned to users with
verifier_2_role_idrole - Approval completes the entire workflow
- Rejection returns submission to admin for revision
Task Creation Logic
Review tasks are created by event listeners with automatic verifier assignment:
// Level 1 task creation (IndicatorSubmissionSubmittedListener)
$verifier1Role = Role::where('name', 'verifier_1_role_id')->first();
if ($verifier1Role && $verifier1Role->users()->exists()) {
$verifier = $verifier1Role->users()->first();
IndicatorReviewTask::create([
'indicator_submission_id' => $submission->id,
'verifier_user_id' => $verifier->id,
'verification_level' => 1,
'status' => IndicatorReviewTaskStatusEnum::PENDING,
]);
}
Usage in Filament
The model is used in the IndicatorVerifications Filament resource:
- User-scoped queries: Only show tasks assigned to current user
- Tabbed interface: Pending vs Completed tasks
- Verification modal: Provides data for approve/reject interface
Query Scoping
public static function getEloquentQuery(): Builder
{
return parent::getEloquentQuery()
->where('verifier_user_id', auth()->id())
->with(['submission.task.indicator', 'submission.task.entrepreneur']);
}
Verification Completion
When a verifier completes their review:
- IndicatorSubmissionReview record is created with decision and feedback
- IndicatorReviewTask status is updated to COMPLETED
- Appropriate event is dispatched (
IndicatorSubmissionApprovedorIndicatorSubmissionRejected) - Next level task may be created or workflow completes
Display in Tables
Review tasks display comprehensive information in verification tables:
- Indicator name and type
- Entrepreneur and organisation details
- Submission date and verification level
- Completion status and date
Role-Based Assignment
Task assignment depends on role availability:
// Verifier role lookup
$verifierRole = Role::where('name', "verifier_{$level}_role_id")->first();
if ($verifierRole && $verifierRole->users()->exists()) {
$verifier = $verifierRole->users()->first();
// Create review task
} else {
// No verifier available - skip this level or complete workflow
}
Query Patterns
User-specific Tasks
// Get pending review tasks for current user
$pendingTasks = IndicatorReviewTask::where('verifier_user_id', auth()->id())
->where('status', IndicatorReviewTaskStatusEnum::PENDING)
->get();
Level-specific Queries
// Get all Level 1 verification tasks
$level1Tasks = IndicatorReviewTask::where('verification_level', 1)->get();
With Related Data
// Eager load for performance
$tasks = IndicatorReviewTask::with([
'submission.task.indicator',
'submission.task.entrepreneur',
'submission.task.organisation',
'review' // If completed
])->get();
Important Notes
- Review tasks are created automatically by event listeners, not manually
- The verification level determines the approval workflow progression
- If no verifiers are available for a level, that level is skipped
- User scoping is critical for proper visibility control in Filament interface
- Completed tasks maintain their assignment for audit purposes
- The relationship with IndicatorSubmissionReview provides access to the actual verification decision and feedback