芝麻web文件管理V1.00
编辑当前文件:/home/qrafawbu/store.kwesioben.com/app/Http/Controllers/Admin/HelpTopicController.php
validate([ 'question' => 'required', 'answer' => 'required', 'ranking' => 'required', ], [ 'question.required' => 'Question name is required!', 'answer.required' => 'Question answer is required!', ]); $helps = new HelpTopic; $helps->question = $request->question; $helps->answer = $request->answer; $request->has('status')? $helps->status = 1 : $helps->status = 0; $helps->ranking = $request->ranking; $helps->save(); Toastr::success(translate('FAQ_added_successfully')); return back(); } public function status($id) { $helps = HelpTopic::findOrFail($id); if ($helps->status == 1) { $helps->update(["status" => 0]); } else { $helps->update(["status" => 1]); } return response()->json(['success' => translate('status_change_successfully')]); } public function edit($id) { $helps = HelpTopic::findOrFail($id); return response()->json($helps); } public function update(Request $request, $id) { $request->validate([ 'question' => 'required', 'answer' => 'required', ], [ 'question.required' => 'Question name is required!', 'answer.required' => 'Question answer is required!', ]); $helps = HelpTopic::find($id); $helps->question = $request->question; $helps->answer = $request->answer; $helps->ranking = $request->ranking; $helps->update(); Toastr::success(translate('FAQ_Update_successfully')); return back(); } function list() { $helps = HelpTopic::latest()->get(); return view('admin-views.help-topics.list', compact('helps')); } public function destroy(Request $request) { $helps = HelpTopic::find($request->id); $helps->delete(); return response()->json(); } }