Esempio n. 1
0
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index(Request $request)
 {
     $name = $request->input('name');
     $artist = $request->input('artist');
     $type = 1;
     $view;
     if (\Auth::check()) {
         if (\Auth::User()->roll == "Administrador") {
             $view = 'songs.index';
         } else {
             if (\Auth::User()->roll == "Cliente") {
                 $view = 'songs.songs_user';
             }
         }
         if ($name == null && $artist == null) {
             $songs = Song::getsongs();
             return view($view, compact('songs'));
         } else {
             if ($name != null && $artist == null) {
                 $songs = \App\Models\Song::search_by_song($name, $type);
                 return view($view, compact('songs'));
             } else {
                 if ($name == null && $artist != null) {
                     $songs = \App\Models\Song::search_by_singer($artist);
                     return view($view, compact('songs'));
                 } else {
                     $songs = \App\Models\Song::search_by_singer_song($name, $artist);
                     return view($view, compact('songs'));
                 }
             }
         }
     } else {
         return view('auth.login');
     }
 }