Skip to content

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 created
  • OVERDUE: System-managed when due_date passes
  • NEEDS_REVISION: Set when verification is rejected
  • SUBMITTED: Set when submission is created
  • COMPLETED: 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 displayStatus for logic
  • Status display in tables using displayLabel for user-friendly text
  • Modal forms access related indicator data for dynamic field generation

Key Fields

  • responsible_user_id: The admin user responsible for completion
  • entrepreneur_id: The entrepreneur this indicator relates to
  • due_date: When the task should be completed
  • status: Current task status (enum)
  • additional_instruction: Helper text displayed in submission forms
  • supporting_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 (displayStatus vs displayLabel) 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