This method i try
$questions = DB::table('questionbank')
->join('questionbank_quizzes','questionbank_id.id','=','questionbank.id')
->join('quizzes','quizzes.id','=','questionbank_quizzes.quize_id')
->where('subject_id', '=', $request->subject_id)
->get(['id', 'subject_id', 'topic_id', 'question_type', 'question', 'marks', 'difficulty_level', 'status','quizzes.title']);
and the error is
"message": "SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'id' in field list is ambiguous (SQL: select `id`, `subject_id`, `topic_id`, `question_type`, `question`, `marks`, `difficulty_level`, `status`, `quizzes`.`title` from `questionbank` inner join `questionbank_quizzes` on `questionbank_id`.`id` = `questionbank`.`id` inner join `quizzes` on `quizzes`.`id` = `questionbank_quizzes`.`quize_id` where `subject_id` = 78)",
"exception": "Illuminate\\Database\\QueryException",
I want to return in this format can any suggest what we have to do? {id: 2665, subject_id: "78", topic_id: "95", question_type: "radio",…}
But in scipt has other method but we have to print same data as above
$subject_id = $request->subject_id;
$subject = Subject::where('id','=',$subject_id)->first();
$topics = $subject
->topics()
->where('parent_id', '=', '0')
->get(['topic_name', 'id']);
$questionbank_id = DB::table('questionbank')
->where('subject_id', '=', $request->subject_id)
->get(['id']);
// $questionbank_quizzes = $questionbank_id->DB::table('questionbank_quizzes')
// ->where('questionbank_id', '=', $questionbank_id[]->id)
// ->get(['quize_id','questionbank_id']);
// $quiz_n=quizzesExistTitle()->get(['title']);
$questions = $subject->questions()->get(['id', 'subject_id', 'topic_id', 'question_type', 'question', 'marks', 'difficulty_level', 'status']);
// $questions = DB::table('questionbank')
// ->join('questionbank_quizzes','questionbank_id.id','=','questionbank.id')
// ->join('quizzes','quizzes.id','=','questionbank_quizzes.quize_id')
// ->where('subject_id', '=', $request->subject_id)
// ->get(['id', 'subject_id', 'topic_id', 'question_type', 'question', 'marks', 'difficulty_level', 'status']);
return json_encode(array('topics'=>$topics, 'questions'=>$questions, 'subject'=>$subject,'questionbank_quizzes'=>$questionbank_id));
}
i have to show in array quizzes.title
I have try
$questions = DB::table('questionbank')
->join('questionbank_quizzes','questionbank_id.id','=','questionbank.id')
->join('quizzes','quizzes.id','=','questionbank_quizzes.quize_id')
->where('subject_id', '=', $request->subject_id)
->get(['id', 'subject_id', 'topic_id', 'question_type', 'question', 'marks', 'difficulty_level', 'status','quizzes.title']);
but got above error
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/rt4XIcS
via IFTTT
Aucun commentaire:
Enregistrer un commentaire