@extends('admin.admin_master') @section('admin')

My Workflows

Manage and track your workflow tasks

@if(session('workflow_completed')) @endif @include('workflow.partials.new-modal', ['allWorkflows' => \App\Models\Workflow::all()])
My Workflow Tasks
@forelse($tasks as $task) @if($task->status !== 'completed') @php $currentStep = $task->step_id ? \App\Models\WorkflowStep::find($task->step_id) : null; $availableTransitions = $task->workflow ? $task->workflow->transitions->where('from_step_id', $task->step_id) : collect(); $history = \App\Models\WorkflowTask::where('document_id', $task->document_id) ->where('status', 'completed') ->with(['transition.fromStep', 'transition.toStep', 'assignedUser']) ->orderBy('created_at') ->orderBy('id') ->get(); @endphp
{{ $task->document->title ?? 'Untitled document' }}
{{ $task->workflow->name ?? '-' }} @if($currentStep)Current: {{ $currentStep->name }}@endif
{{ ucfirst(str_replace('_', ' ', $task->status)) }}
@if($task->document && $task->document->description)

{{ $task->document->description }}

@endif {{-- Previous steps & their comments --}} @if($history->count())
Previous steps
    @foreach($history as $h) @php $fromOrder = optional(optional($h->transition)->fromStep)->order; $toOrder = optional(optional($h->transition)->toStep)->order; $isReturn = !is_null($fromOrder) && !is_null($toOrder) && $toOrder < $fromOrder; $hu = $h->assignedUser; $huName = $hu ? (trim(($hu->first_name ?? '') . ' ' . ($hu->last_name ?? '')) ?: ($hu->name ?? 'User')) : null; @endphp
  • {{ optional($h->transition)->name ?? 'Action' }} ({{ optional(optional($h->transition)->fromStep)->name ?? 'Start' }} → {{ optional(optional($h->transition)->toStep)->name ?? '-' }}) @if($huName){{ $huName }}@endif @if($h->created_at) · {{ $h->created_at->format('Y-m-d H:i') }}@endif
    @if(trim((string) $h->comment) !== '')
    {{ $h->comment }}
    @else
    No comment
    @endif
  • @endforeach
@endif {{-- Action form --}} @if($availableTransitions->count())
@csrf
View Details
@else
No actions available from the current step.
@endif
@endif @empty
No workflow tasks assigned to you.
@endforelse
Workflows I Created
@php $createdWorkflowIds = \App\Models\Workflow::where('created_by', auth()->id())->pluck('id'); $documents = \App\Models\Document::whereIn('workflow_id', $createdWorkflowIds) ->with(['workflow', 'tasks.assignedUser', 'tasks.assignedRole', 'tasks.transition.fromStep', 'tasks.transition.toStep']) ->orderByDesc('created_at')->get(); @endphp @forelse($documents as $doc) @empty @endforelse
Document Title Workflow Created At View Tasks
{{ $doc->title }}
{{ $doc->description }}
{{ $doc->workflow ? $doc->workflow->name : '-' }} {{ $doc->created_at ? $doc->created_at->format('Y-m-d H:i') : '-' }} @if($doc->file_path) View @else No file @endif @if($doc->tasks && $doc->tasks->count()) @else No tasks @endif
No documents found for workflows you created.
@endsection