/**
  * 动作:激活账号
  * @param  string $activationCode 激活令牌
  * @return Response
  */
 public function getActivate($activationCode)
 {
     // 数据库验证令牌
     $activation = Activation::where('token', $activationCode)->first();
     // 数据库中无令牌,抛出404
     is_null($activation) and App::abort(404);
     // 数据库中有令牌
     // 激活对应用户
     $user = User::where('email', $activation->email)->first();
     $user->activated_at = new Carbon();
     $user->save();
     // 删除令牌
     $activation->delete();
     // 激活成功提示
     return View::make('authority.activationSuccess');
 }
Exemplo n.º 2
0
 /**
  * Handling user activation
  *
  * return @Response
  */
 public function activation($code)
 {
     $code = Activation::where('code', '=', $code)->first();
     if ($code) {
         $user = User::find($code->user);
         if ($user) {
             Auth::login($user);
         }
         $code->delete();
         $result = ['success' => true];
         if ($user->type == 'artist') {
             return View::make('artist.activation', $result);
         }
         if ($user->type == 'charity') {
             return View::make('charity.activation', $result);
         }
         if ($user->type == 'customer') {
             return View::make('customer.activation', $result);
         }
     } else {
         return View::make('charity.activation');
     }
 }
 /**
  * Show artist profile
  * 
  * return @Response
  */
 public function showprofile($user)
 {
     $profile = User::where('profile_url', '=', $user)->where('approved', '=', '0')->where('deleted_at', '=', null)->first();
     if (!is_null($profile)) {
         $activation = Activation::where('user', '=', $profile->id)->first();
         $page = Page::where('title', '=', 'faq-artist')->first();
         $transactions = Purchase::where('artist', '=', $profile->id)->get();
         if ($activation) {
             return View::make('artist.not-activated');
         } else {
             if ($profile) {
                 if ($profile->active == 1) {
                     $songs = Song::where('artist', '=', $profile->id)->where('completed', '=', '1')->orderBy('id', 'desc')->paginate(10);
                     $bundles = Bundle::where('artist', '=', $profile->id)->get();
                     $wall = new \Illuminate\Database\Eloquent\Collection();
                     $wall = $wall->merge($songs);
                     $wall = $wall->merge($bundles);
                     //dd($wall);
                     $followers = Follow::where('artist', '=', $profile->id)->get();
                     $countries = [];
                     foreach ($followers as $f) {
                         if (empty($f->profile->country)) {
                             $f->profile->country = 'Country unknown';
                         }
                         if (isset($countries[$f->profile->country])) {
                             $countries[$f->profile->country]++;
                         } else {
                             $countries[$f->profile->country] = 1;
                         }
                     }
                     $events = ArtistEvent::where('artist', '=', $profile->id)->where('date', '>', \Carbon\Carbon::now())->orderBy('id', 'desc')->take(3)->get();
                     $songs_in = [];
                     foreach ($songs as $s) {
                         $songs_in[] = $s->id;
                     }
                     if (count($songs_in) > 0) {
                         $comments = Comment::whereIn('song', $songs_in)->orderBy('id', 'desc')->take(3)->get();
                     } else {
                         $comments = "";
                     }
                     $wall->sortByDesc('created_at');
                     //dd($wall);
                     $notifications = MyNotification::where('user', '=', $profile->id)->get();
                     return View::make('artist.profile-new', ['profile' => $profile, 'songs' => $songs, 'events' => $events, 'comments' => $comments, 'notifications' => $notifications, 'wall' => $wall, 'page' => $page, 'transactions' => $transactions, 'countries' => $countries]);
                 } else {
                     return Redirect::to('profile/settings');
                 }
             } else {
                 App::abort(404);
             }
         }
     } else {
         App::abort(404);
     }
 }
 /**
  * Action: Activate account
  * @param  string $activationCode Activation tokens
  * @return Response
  */
 public function getActivate($activationCode)
 {
     // Database authentication tokens
     $activation = Activation::where('token', $activationCode)->first();
     // No tokens in the database, throw 404
     is_null($activation) and App::abort(404);
     // Database tokens
     // Activate the corresponding user
     $user = User::where('email', $activation->email)->first();
     $user->activated_at = new Carbon();
     $user->save();
     // Delete tokens
     $activation->delete();
     // Activation success
     return View::make('authority.activationSuccess');
 }