where('subject_id', $data['subject_id']) ->where('class_id', $data['class_id']) ->where('academic_year', $data['academic_year']) ->exists(); if ($exists) { Notification::make() ->title('Failed to save') ->body('The combination of teacher, subject, class, and academic year is already registered.') ->danger() ->send(); $this->halt(); } return $data; } }