public function getViewQuery($id) { $menu = Menu::Orderby('id', 'des')->get(); $query = Queries::where('id', $id)->get()[0]->query; $subject = Queries::where('id', $id)->get()[0]->subject; $user = User::where('username', Session::get('username'))->first(); if (\Auth::Check()) { if ($user->level == 0) { if (Session::get('err') == '1') { return redirect('queries'); } else { return view('view_query', ['subject' => $subject, 'query' => $query, 'id' => $id])->with('username', $user->username)->with('level', $user->level)->with('menu', $menu); } } else { return redirect('/'); } } else { return redirect('login'); } }
public function postReply($id) { if (\Auth::check()) { $data = Input::all(); array_pop($data); $validator = Validator::make($data, ['reply' => 'required']); if ($validator->fails()) { return Redirect::back()->withErrors($validator->errors())->withInput(); } else { $query = Queries::where('id', $id)->first(); $query->reply = $data['reply']; $query->replied = 1; $query->save(); return redirect('queries'); } } else { return redirect('login'); } }
public function getUserQueries() { $menu = Menu::Orderby('id', 'des')->get(); $queries = Queries::where('username', Session::get('username'))->get(); $id = 1; if (\Auth::Check()) { $user = User::where('username', Session::get('username'))->first(); return view('user_queries')->with('username', $user->username)->with('level', $user->level)->with('queries', $queries)->with('id', $id)->with('menu', $menu); } else { return redirect('login'); } }