/** * Store a newly feedback in storage. * * @param \Illuminate\Http\Request|CreateFeedbackRequest $request * @return \Illuminate\Http\Response */ public function store(CreateFeedbackRequest $request) { $feedback = new Feedback(); $feedback->fill($request->all()); if ($feedback->save()) { $this->sendAdminFeedbackNotification($feedback); return redirect(route('page.contact') . '#feedback')->with(['status' => 'success', 'message' => Lang::get('alert.feedback.send')]); } return redirect()->back()->withErrors(['error' => Lang::get('alert.error.database')]); }
/** * Display a administrator dashboard. * * @return \Illuminate\Http\Response */ public function index() { $activities = Activity::with('contributor')->paginate(8); $statistics = ['ARTICLES' => Article::count(), 'MEMBERS' => Contributor::count(), 'CATEGORIES' => Subcategory::count(), 'MESSAGES' => Message::count(), 'FEEDBACK' => Feedback::count(), 'VISITORS' => (int) Visitor::sum('unique')]; $visitors = Visitor::take(10)->get(); return view('admin.dashboard.index', compact('activities', 'statistics', 'visitors')); }
/** * Remove the specified feedback from storage. * * @param Request $request * @param int $id * @return \Illuminate\Http\Response */ public function destroy(Request $request, $id) { /* * -------------------------------------------------------------------------- * Delete feedback * -------------------------------------------------------------------------- * Check if selected variable is not empty so user intends to select multiple * rows at once, and prepare the feedback message according the type of * deletion action. */ $selected = $request->input('selected'); if (!empty(trim($selected))) { $feedback_ids = explode(',', $selected); $delete = Feedback::whereIn('id', $feedback_ids)->delete(); $message = Lang::get('alert.feedback.delete_all', ['count' => $delete]); } else { $feedback = Feedback::findOrFail($id); $message = Lang::get('alert.feedback.delete', ['name' => $feedback->name]); $delete = $feedback->delete(); } if ($delete) { return redirect(route('admin.feedback.index'))->with(['status' => 'warning', 'message' => $message]); } else { return redirect()->back()->withErrors(['error' => Lang::get('alert.error.database')]); } }