@php use App\Models\AssignedClassTeacher; use App\Models\Teacher; $id = Auth::user()->id; $TeacherData = App\Models\User::findOrFail($id); $teacherphoto = Teacher::where( 'user_id', $id )->first(); /* |-------------------------------------------------------------------------- | CHECK IF LOGGED-IN TEACHER IS A CLASS TEACHER |-------------------------------------------------------------------------- | | We only use this to control sidebar visibility. | | The controller still performs the real authorization/security check. | */ $isClassTeacher = false; if ($teacherphoto) { $isClassTeacher = AssignedClassTeacher::where( 'teacher_id', $teacherphoto->id )->exists(); } @endphp