@php($teams=$data['teams']) @if(!$teams->isEmpty()) @foreach($teams as $team) @php($total_task = DB::table('tasks')->where('task_owner', $team->admin_uuid)->where('task_related_to', 'Lead')->where('task_linked_with_uuid', $data['lead'])->count()) @php($completed_task_stage_uuid = DB::table('task_stage')->where('is_completed', 1)->first()) @php($progress_task_stage_uuid = DB::table('task_stage')->where('is_completed','!=', 1)->first()) @php($completed_task = DB::table('tasks')->where('task_owner', $team->admin_uuid)->where('task_related_to', 'Lead')->where('task_linked_with_uuid', $data['lead'])->where('task_stage', $completed_task_stage_uuid->record_uuid)->count()) @php($progress_task = DB::table('tasks')->where('task_owner', $team->admin_uuid)->where('task_related_to', 'Lead')->where('task_linked_with_uuid', $data['lead'])->where('task_stage', $progress_task_stage_uuid->record_uuid)) @php($progress_task_count = $progress_task->count()) @php($progress_task_sum = $progress_task->sum('estimated_time_to_complete')) @php($last_task_estimate = $progress_task->orderBy('id', 'desc')->first()) @php($total_percentage = 0)