/**
  * Handle a registration request for the application.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function register(Request $request)
 {
     $validator = $this->validator($request->all());
     if ($validator->fails()) {
         $this->throwValidationException($request, $validator);
     }
     //Auth::login($this->create($request->all()));
     $this->create($request->all());
     //Send confirmation mail/////////////////////////////////////////////////////////////////////////////////
     $email = $request['email'];
     //creating the token
     $token = substr(Crypt::encrypt($email . str_random(10)), 0, 100);
     //Enter the token and email into database
     $user_verification = new UserVerification();
     $user_verification->email = $email;
     $user_verification->verification_token = $token;
     $user_verification->save();
     //return URL::to('/')."/email_confirmation/".$token;  //for fast testing
     //Now send the mail
     Mail::send('auth.emails.welcome', ['url' => URL::to('/') . '/email_confirmation/' . $token], function ($message) use($email) {
         $message->to($email, 'Laravel 5.2 App')->subject('Activate Your Account !');
     });
     return redirect($this->redirectPath());
 }
 public function email_confirmation($token)
 {
     //find verification info
     $user_verification = UserVerification::where('verification_token', $token);
     if ($user_verification->count()) {
         $user_verification = $user_verification->first();
         //find user
         $user = User::where('email', $user_verification->email)->first();
         //update user
         $user->is_active = 'active';
         $user->save();
         //delete verification info - optional
         $user_verification->delete();
         return 'Your account is activated. You can login from <a href="' . URL::to('/login') . '" target="_blank">here</a>';
     } else {
         return "Wrong URL or token";
     }
 }