public function delete(Question $question, $id)
 {
     $lessonquestions = $question->findOrFail($id);
     $questions = $question->findOrFail($id)->delete();
     $message = "تم حذف المادة بنجاح";
     return redirect()->route('questionbank.questionlist', $lessonquestions->lesson_id)->with('success', $message);
 }
 public function deletequestion($id, $activity_id)
 {
     $question = Question::findOrFail($id);
     $lesson = Lesson::findOrFail($question->lesson_id);
     $question = Question::with('exam')->findOrFail($id);
     /*
     		if(!$question->exam->isEmpty()) {
     			return redirect()->back()->with('error', 'لا يمكن حذف السؤال لانه مستخدم في اختبار');
     		}*/
     $question->delete();
     //$exam = Exam::findOrFail($activity_id);
     //$exam->questions()->detach([$question_id]);
     $message = "تم حذف السؤال بنجاح";
     return redirect()->route('teachers.profile.questions', $activity_id)->with('success', $message);
 }
 public function delete($id)
 {
     $question = Question::findOrFail($id);
     $lesson = Lesson::findOrFail($question->lesson_id);
     $question = Question::with('exam')->findOrFail($id);
     if (!$question->exam->isEmpty()) {
         return redirect()->back()->with('error', 'لا يمكن حذف السؤال لانه مستخدم في اختبار');
     }
     $question->delete();
     $message = "تم حذف السؤال بنجاح";
     return redirect()->route('questionbank.question', $lesson->subject_subject_id)->with('success', $message);
 }