public function saveSettings()
 {
     $data = Input::all();
     $profile = new Profile();
     $profile->deleteMyEmailNotifications(Auth::id());
     $profile->saveMyEmailNotifications(Auth::id(), $data);
     return Alert::flash(Lang::get('auth.settings-updated'), 'success');
 }
 public function thumbsUp($id, $slug)
 {
     $post = Post::where('id', $id)->where('slug', $slug)->with('user.profile')->firstOrFail();
     if (!Vote::setVotePoints($post)) {
         return Alert::flash(Lang::get('post.vote'), 'warning');
     }
     return Redirect::action('post', [$id, $slug]);
 }
 public function send()
 {
     $data = Input::all();
     $rules = ['full_name' => ['required', 'min:3', 'max:35'], 'email' => ['required', 'email'], 'content' => ['required', 'min:10', 'max:600']];
     $validator = Validator::make($data, $rules);
     if ($validator->fails()) {
         return Alert::formError($validator);
     }
     Mailing::contact($data);
     return Alert::flash(Lang::get('contact.sent'), 'success');
 }
 private function displayForm($type)
 {
     $title = "Post Comment";
     $currentQuestion = Question::getCurrentQuestion();
     $points_pct = Question::getTotalPointsPct($currentQuestion);
     $remaining_time = Question::getRemainingTime($currentQuestion);
     $posts = Post::getRandPosts($currentQuestion);
     if (Post::hasPost($currentQuestion)) {
         return Alert::flash(Lang::get('post.exist'), 'warning');
     }
     $options = [$currentQuestion['left_option'] => ucfirst($currentQuestion['left_option']), $currentQuestion['right_option'] => ucfirst($currentQuestion['right_option'])];
     return View::make("posts.options.{$type}")->with(['question' => $currentQuestion, 'remaining_time' => $remaining_time, 'points_pct' => $points_pct, 'posts' => $posts, 'options' => $options, 'title' => $title]);
 }
 public static function adminUpdateUser($id)
 {
     $data = Input::all();
     $rules = ['email' => ['required', 'email', 'max:128', 'unique:users,email,' . Auth::id()], 'username' => ['required', 'min:5', 'max:15', 'alpha_num', 'unique:users,username,' . Auth::id()]];
     $validator = Validator::make($data, $rules);
     if ($validator->fails()) {
         return Alert::formError($validator);
     } else {
         $user = new User();
         $update = User::UpdateUser($id, $data);
         return Alert::flash(Lang::get('admin.user-updated'), 'success');
     }
 }
 public function passwordUpdate()
 {
     $data = Input::only('email', 'password', 'password_confirmation', 'token');
     $response = Password::reset($data, function ($user, $password) {
         $user->password = $password;
         $user->save();
     });
     switch ($response) {
         case Password::INVALID_PASSWORD:
         case Password::INVALID_TOKEN:
         case Password::INVALID_USER:
             return Alert::flash(Lang::get($response), 'error');
         case Password::PASSWORD_RESET:
             return Alert::flash(Lang::get('reminders.reset'), 'success');
     }
 }