IndicatorTask
Intro
The IndicatorTask model represents tasks assigned to administrators for completing indicator submissions. These tasks are central to the Indicators workflow and serve as the primary entry point for the admin submission process.
Model and Relationships
The IndicatorTask model has the following key relationships:
- Indicator: Belongs-to relationship with IndicatorSuccess or IndicatorCompliance models (polymorphic)
- Assigned User: Belongs-to relationship with the User model (responsible_user_id)
- Entrepreneur: Belongs-to relationship with the User model (entrepreneur_id)
- Organisation: Belongs-to relationship with the Organisation model
- Programme: Belongs-to relationship with the Programme model
- Submissions: Has-many relationship with IndicatorSubmission model
Status Management
The model uses the IndicatorTaskStatusEnum for status management:
PENDING: Initial status when task is createdOVERDUE: System-managed when due_date passesNEEDS_REVISION: Set when verification is rejectedSUBMITTED: Set when submission is createdCOMPLETED: Final status when verification is approved
Display Attributes
The model provides two key attributes for status display:
displayStatus()
Returns the IndicatorTaskStatusEnum object for programmatic use:
public function getDisplayStatusAttribute(): IndicatorTaskStatusEnum
{
if ($this->status === IndicatorTaskStatusEnum::PENDING &&
$this->due_date && $this->due_date->isPast()) {
return IndicatorTaskStatusEnum::OVERDUE;
}
return $this->status;
}
Scopes
User-scoped Queries
Tasks are typically queried by assigned user:
$userTasks = IndicatorTask::where('responsible_user_id', auth()->id())->get();
Status-based Filtering
// Pending tasks (including overdue and needs revision)
$pendingTasks = IndicatorTask::whereIn('status', [
IndicatorTaskStatusEnum::PENDING,
IndicatorTaskStatusEnum::NEEDS_REVISION,
IndicatorTaskStatusEnum::OVERDUE
])->get();
Usage in Filament
The model is used extensively in the IndicatorSubmissions Filament resource:
- Table queries are user-scoped for visibility control
- Status-based tab filtering using
displayStatusfor logic - Status display in tables using
displayLabelfor user-friendly text - Modal forms access related indicator data for dynamic field generation
Key Fields
responsible_user_id: The admin user responsible for completionentrepreneur_id: The entrepreneur this indicator relates todue_date: When the task should be completedstatus: Current task status (enum)additional_instruction: Helper text displayed in submission formssupporting_documentation: Boolean indicating if file uploads are required
Important Notes
- Tasks are created through existing mechanisms (not part of this feature)
- The dual status system (
displayStatusvsdisplayLabel) serves different purposes - Status transitions are managed by event listeners, not directly on the model
- User scoping is critical for proper visibility control in the Filament interface