예제 #1
0
 public function postSuggest()
 {
     if (\Auth::Check()) {
         $data = Input::all();
         array_pop($data);
         $rules = ['username' => 'required', 'title' => 'required', 'author' => 'required', 'publisher' => 'required', 'edition' => 'required', 'volume' => 'required', 'review' => 'required'];
         $validator = Validator::make($data, $rules);
         if ($validator->fails()) {
             return Redirect::back()->withErrors($validator->errors())->withInput();
         } else {
             $suggestion = new Suggestions();
             $suggestion->username = $data['username'];
             $suggestion->title = $data['title'];
             $suggestion->author = $data['author'];
             $suggestion->publisher = $data['publisher'];
             $suggestion->edition = $data['edition'];
             $suggestion->volume = $data['volume'];
             $suggestion->review = $data['review'];
             $suggestion->save();
             Session::flash('err', "1");
             return redirect('suggest');
         }
     } else {
         return redirect('login');
     }
 }
예제 #2
0
 public function getViewSuggestion($id)
 {
     $menu = Menu::Orderby('id', 'des')->get();
     if (\Auth::Check()) {
         $title = Suggestions::where('id', $id)->get()[0]->title;
         $author = Suggestions::where('id', $id)->get()[0]->author;
         $publisher = Suggestions::where('id', $id)->get()[0]->publisher;
         $edition = Suggestions::where('id', $id)->get()[0]->edition;
         $volume = Suggestions::where('id', $id)->get()[0]->volume;
         $review = Suggestions::where('id', $id)->get()[0]->review;
         $user = User::where('username', Session::get('username'))->first();
         if ($user->level == 0) {
             return view('view_suggestion', ['title' => $title, 'author' => $author, 'publisher' => $publisher, 'edition' => $edition, 'volume' => $volume, 'review' => $review])->with('username', $user->username)->with('level', $user->level)->with('menu', $menu);
         } else {
             return redirect('/');
         }
     } else {
         return redirect('login');
     }
 }