Ejemplo n.º 1
0
 public function search(Request $request)
 {
     $authors = User::all();
     if ($request->search) {
         $adventures = Adventure::where('name', 'LIKE', '%' . $request->search . '%')->orWhere('description', 'LIKE', '%' . $request->search . '%')->paginate(5);
     } else {
         $adventures = Adventure::paginate(5);
     }
     foreach ($adventures as $adventure) {
         $normalVotes = count($adventure->votes);
         $adventure->total_votes = $adventure->anonymous_votes + $normalVotes;
     }
     return view("adventures.index", compact("adventures", "authors"));
 }
Ejemplo n.º 2
0
Archivo: User.php Proyecto: abreban/RGU
 public function adventures()
 {
     $adventures = Adventure::where('user_id', $this->id)->get();
     return $adventures;
 }