In my question answers project, the admin has a functionality to view all questions and delete each one if he wishes. but one question id has 5 related tables. that is , each question id is present in 5 tables in db and when admin deletes one question i have to delete all the entries from these 5 tables based on this question id.
in my controller
DB::table('user_questions')->where('question_id','=',$question_id)->delete();
DB::table('masters_answers')->where('question_id','=',$question_id)->delete();
DB::table('masters_questions')->where('question_id','=',$question_id)->delete();
DB::table('question_to_category')->where('question_id','=',$question_id)->delete();
DB::table('question_to_tags')->where('question_id','=',$question_id)->delete();
return Redirect::action('AdminController@anyShowQuestions', array());
The above code will works but is there any way for do the same procedure in one db query in laravel.? i had referred this post but cannot find a solution for mine. it will be so helpful if anyone suggest a right way??