@php $statuses = ['' => 'Any status','todo'=>'To do','in_progress'=>'In progress','blocked'=>'Blocked','done'=>'Done']; $dueOpts = ['' => 'Any due','overdue' => 'Overdue','today' => 'Due today','week' => 'Due next 7 days','none' => 'No due date']; $priorities = ['', 'low', 'medium', 'high', 'urgent']; @endphp

{{ $project->name }}

{{ $project->description }}

@if ($project->user_id === auth()->id() || in_array(auth()->id(), $followers))
@csrf
@foreach($project->sections as $section) @if ($section->name === 'To Do') @endif @endforeach
@csrf
@if ($project->status !== 'done') @endif
Manage Followers
@endif
@foreach($project->sections as $section)

{{ $section->name }}


@php $taskQuery = $section->tasks() ->when(request('mine') == '1', fn($q) => $q->where('assignee_id', auth()->id())) ->when(!request('mine') && request('assignee_id'), fn($q,$v) => $q->where('assignee_id',$v)) ->when(request('status'), fn($q,$v) => $v ? $q->where('status',$v) : $q) ->when(request('due') === 'overdue', fn($q) => $q->whereNotNull('due_on')->whereDate('due_on','<', now()->toDateString())->where('status','!=','done')) ->when(request('due') === 'today', fn($q) => $q->whereDate('due_on', now()->toDateString())) ->when(request('due') === 'week', fn($q) => $q->whereBetween('due_on', [now()->toDateString(), now()->addDays(7)->toDateString()])) ->when(request('due') === 'none', fn($q) => $q->whereNull('due_on')) ->when(request('q'), function($q,$term) { $q->where(function($qq) use ($term){ $qq->where('name','like','%'.$term.'%') ->orWhere('description','like','%'.$term.'%') ->orWhereHas('comments', fn($cq)=>$cq->where('body','like','%'.$term.'%')); }); }); $sort = request('sort'); if ($sort === 'overdue_first') { $taskQuery->orderByRaw("CASE WHEN status != 'done' AND due_on IS NOT NULL AND due_on < CURDATE() THEN 0 WHEN due_on IS NOT NULL THEN 1 ELSE 2 END ASC")->orderBy('due_on','asc')->orderBy('sort_order','asc'); } elseif ($sort === 'due_asc') { $taskQuery->orderByRaw('due_on IS NULL')->orderBy('due_on','asc'); } elseif ($sort === 'due_desc') { $taskQuery->orderByRaw('due_on IS NULL')->orderBy('due_on','desc'); } elseif ($sort === 'priority_desc') { $taskQuery->orderByRaw("FIELD(priority,'urgent','high','medium','low')")->orderBy('sort_order','asc'); } elseif ($sort === 'updated_desc') { $taskQuery->orderBy('updated_at','desc'); } else { $taskQuery->orderBy('sort_order','asc')->orderBy('id','asc'); } $tasks = $taskQuery->get(); @endphp
@forelse($tasks as $task) @php $isOverdue = $task->status !== 'done' && $task->due_on && $task->due_on->lt(now()->startOfDay()); $isDueSoon = $task->status !== 'done' && $task->due_on && $task->due_on->gte(now()->startOfDay()) && $task->due_on->lte(now()->addDays(2)->endOfDay()); @endphp
{{ $task->name }}
@if($isOverdue) Overdue @elseif($isDueSoon) Due soon @endif
@if($task->description)
{{ \Illuminate\Support\Str::limit($task->description,140) }}
@endif
@if (($project->user_id === auth()->id() || in_array(auth()->id(), $followers)) && $task->status !== 'done')
@csrf
@else
@foreach(\App\Models\User::orderBy('name')->get() as $u) @if ($task->assignee?->id === $u->id) @endif @endforeach
@endif
@if (($project->user_id === auth()->id() || in_array(auth()->id(), $followers)) && $task->status !== 'done')
@csrf
@if ($task->status !== 'done') @endif
@else
@if ($task->status === 'done')
@endif @endif
@if (($project->user_id === auth()->id() || in_array(auth()->id(), $followers)) && $task->status !== 'done')
@csrf
@if ($task->status !== 'done') @endif
@else
@endif
@if (($project->user_id === auth()->id() || in_array(auth()->id(), $followers)) && $task->status !== 'done')
@csrf
@else
@foreach ($project->tasks as $task2) @if ($task2->id === $task->depends_on) @endif @endforeach
@endif
@if (isset($comments[$task->id])) @endif @if ($task->status !== 'done')
@csrf
@endif
@empty
No tasks match.
@endforelse
@endforeach