예제 #1
0
 public function follow($slug)
 {
     $hub = Hub::where('slug', '=', $slug)->first();
     $user = Auth::user();
     if (!is_null($hub)) {
         $f = Follow::where('user', '=', $user->id)->where('hub', '=', $hub->id)->first();
         if (is_null($f)) {
             $f = new Follow();
             $f->hub = $hub->id;
             $f->user = $user->id;
             $f->save();
             return Redirect::to('hubs/' . $hub->slug);
         } else {
             $f->delete();
             return Redirect::to('hubs/' . $hub->slug);
         }
     } else {
         App::abort('404');
     }
 }
 public function follow($artist)
 {
     $artist = User::where('profile_url', '=', $artist)->first();
     $user = Auth::user();
     if (!is_null($artist)) {
         $f = Follow::where('user', '=', $user->id)->where('artist', '=', $artist->id)->first();
         if (is_null($f)) {
             $f = new Follow();
             $f->artist = $artist->id;
             $f->user = $user->id;
             $f->save();
             return Redirect::to('artist/' . $artist->profile_url);
         } else {
             $f->delete();
             return Redirect::to('artist/' . $artist->profile_url);
         }
     } else {
         App::abort('404');
     }
 }