/**
  * Display customer profile
  *
  * @param $profile
  * @return Response
  */
 public function show($profile)
 {
     $p = User::where('profile_url', '=', $profile)->where('approved', '=', '0')->first();
     $page = Page::where('title', '=', 'faq-customer')->first();
     $follow = Follow::where('user', $p->id)->where('hub', '=', 0)->get();
     $follow_hub = Follow::where('user', $p->id)->where('artist', '=', 0)->get();
     $wall = new \Illuminate\Database\Eloquent\Collection();
     $events = new \Illuminate\Database\Eloquent\Collection();
     $comments = Comment::where('user', '=', $p->id)->orderBy('created_at', 'desc')->get();
     $hidden = unserialize(Cookie::get('hide'));
     //dd( Cookie::get('hide') );
     if (count($follow) > 0) {
         foreach ($follow as $f) {
             $s = Song::where('artist', '=', $f->artist)->where('completed', '=', '1')->get();
             $e = ArtistEvent::where('artist', '=', $f->artist)->where('date', '>', \Carbon\Carbon::now())->get();
             $wall = $wall->merge($s);
             $events = $events->merge($e);
         }
     }
     if (count($follow_hub) > 0) {
         foreach ($follow_hub as $h) {
             $hub = Hub::where('id', '=', $h->hub)->first();
             if (!is_null($hub)) {
                 $artists = User::where('type', '=', 'artist')->where('hub', '=', $hub->id)->get();
                 $artists_list = [];
                 $songs = [];
                 $events = [];
                 foreach ($artists as $a) {
                     $artists_list[] = $a->id;
                 }
                 if (count($artists_list) > 0) {
                     $songs = Song::where('completed', '=', '1')->whereIn('artist', $artists_list)->orderBy('created_at', 'desc')->get();
                     $events = ArtistEvent::whereIn('artist', $artists_list)->get();
                 }
                 $news = News::where('hub', '=', $hub->id)->take(3)->get();
                 $wall = $wall->merge($songs);
                 $events = $events->merge($events);
             }
         }
     }
     $purchased = Purchase::where('customer', '=', $p->id)->get();
     foreach ($purchased as $pp) {
         $song_purchased = Song::withTrashed()->where('id', '=', $pp->song)->get();
         $download = Download::where('customer', '=', $p->id)->where('song', '=', $pp->song)->first();
         $song_purchased[0]->purchased = true;
         if (isset($download)) {
             $song_purchased[0]->link = $download->url;
         }
         $wall = $wall->merge($song_purchased);
     }
     $wall->sortByDesc('created_at');
     if (!isset($news)) {
         $news = null;
     }
     return View::make('customer.profile-new', ['profile' => $p, 'wall' => $wall, 'page' => $page, 'events' => $events, 'comments' => $comments, 'hidden' => $hidden, 'news' => $news]);
 }
示例#2
0
 /**
  * Downvotes the specific comment.
  * @param string $title
  * @param string $slug
  * @return Response
  */
 public function downvote($title, $slug)
 {
     $post = Post::where('slug', '=', $slug)->firstOrFail();
     $hub = Hub::where('name', '=', $title)->firstOrFail();
     if ($post->hub_id === $hub->id) {
         $voted = explode(',', $post->voted);
         if (!in_array(Auth::user()->id, $voted)) {
             $post->voted .= Auth::user()->id . ',';
             $post->downvotes += 1;
             $post->push();
             return response()->json(["success" => true]);
         }
     }
 }
 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');
     }
 }