public function deleteBulk(CategoryRequest $request, Category $CategoryModel)
 {
     // if the table_records is empty we redirect to the subject index
     if (!$request->has('table_records')) {
         return redirect()->route('f.category.index');
     }
     $message = "تم حذف التصنيفات بنجاح";
     // we get all the ids and put them in a variable
     $ids = $request->input('table_records');
     // we delete all the subject with the ids $ids
     $CategoryModel->destroy($ids);
     // we redirect to the user index view with a success message
     return redirect()->route('f.category.index')->with('success', $message);
 }
 public function index($cat_id)
 {
     $faqs = QuestionsAnswers::where('cat_id', $cat_id)->paginate(20);
     $category_name = Category::findOrFail($cat_id);
     $category_name = $category_name->name;
     return view('faq::faqs.index', compact('faqs', 'cat_id', 'category_name'));
 }
 /**
  * Register the service provider.
  *
  * @return void
  */
 public function register()
 {
     //Category
     Category::created(function ($category) {
         UserLog::create(['operation' => 'create', 'user_id' => user() ? user()->id : NULL, 'reference_key' => 'FAQ_category', 'reference_id' => $category->id]);
     });
     Category::updated(function ($category) {
         UserLog::create(['operation' => 'update', 'user_id' => user() ? user()->id : NULL, 'reference_key' => 'FAQ_category', 'reference_id' => $category->id]);
     });
     Category::deleted(function ($category) {
         UserLog::create(['operation' => 'delete', 'user_id' => user() ? user()->id : NULL, 'reference_key' => 'FAQ_category', 'reference_id' => $category->id]);
     });
     //QuestionsAnswers
     QuestionsAnswers::created(function ($questionsanswer) {
         UserLog::create(['operation' => 'create', 'user_id' => user() ? user()->id : NULL, 'reference_key' => 'FAQ_questionsanswer', 'reference_id' => $questionsanswer->id]);
     });
     QuestionsAnswers::updated(function ($questionsanswer) {
         UserLog::create(['operation' => 'update', 'user_id' => user() ? user()->id : NULL, 'reference_key' => 'FAQ_questionsanswer', 'reference_id' => $questionsanswer->id]);
     });
     QuestionsAnswers::deleted(function ($questionsanswer) {
         UserLog::create(['operation' => 'delete', 'user_id' => user() ? user()->id : NULL, 'reference_key' => 'FAQ_questionsanswer', 'reference_id' => $questionsanswer->id]);
     });
 }
 public function show(Category $category)
 {
     $category->load('questions');
     return view('faq::students.show', compact('category'));
 }