@php $record = $getRecord(); $stepId = $record->id; $team = $record->team; $users = $team->students; $attendedUsers = \App\Models\Attendance::where('team_path_step_id', $stepId) ->pluck('user_id') ->toArray(); @endphp Student Status Action @foreach ($users as $user) {{ $user->name }} @if(in_array($user->id, $attendedUsers)) Present @else Absent @endif @if(!in_array($user->id, $attendedUsers)) Mark Present @else Undo @endif @endforeach