Ejemplo n.º 1
0
 public function postRegister(Request $request)
 {
     # Get the input from the registration form
     $userName = $request->input('user-name');
     $password = $request->input('password');
     $passwordConfirm = $request->input('password-confirm');
     $email = $request->input('email-address');
     $userExists = \p4\User::where('user_name', $userName)->orwhere('email', $email)->exists();
     $input = array('email' => $email, 'password' => $password, 'password_confirmation' => $passwordConfirm, 'user_name' => $userName);
     $rules = ['user_name' => 'required|min:3|max:30|unique:users', 'email' => 'required|email|unique:users', 'password' => 'required|confirmed|min:6|max:20'];
     $validator = \Validator::make($input, $rules);
     if ($validator->fails()) {
         return redirect('Register')->withErrors($validator)->withInput();
     }
     if (!$userExists) {
         # Register this User
         $newUser = \p4\User::create(['user_name' => $userName, 'password' => bcrypt($password), 'status' => 'A', 'email' => $email]);
         # Create Default My Feeds Category
         $default = new \p4\Category();
         $default->user_id = $newUser->id;
         $default->name = "My Feeds";
         $default->weight = 50;
         $default->save();
         $message = "You have been registered. Please login to continue.";
     }
     return view('login', ['message' => $message]);
 }
Ejemplo n.º 2
0
 public function postAddCategory(Request $request)
 {
     $user_id = \Auth::user()->id;
     // Validate Edit Form Input
     $input = array('category_name' => $request->input('new-category-name'), 'category_weight' => $request->input('new-category-weight'));
     $validator = Validator::make($input, ['category_name' => 'required|min:3|max:50', 'category_weight' => 'required|integer|min:1|max:100']);
     if ($validator->fails()) {
         return redirect('/ManageCategories')->withErrors($validator)->withInput();
     }
     $categoryName = $request->input('new-category-name');
     $categoryWeight = $request->input('new-category-weight');
     $category = new \p4\Category();
     $category->user_id = $user_id;
     $category->name = $categoryName;
     $category->weight = $categoryWeight;
     $category->save();
     \p4\User::setSessionFeeds($user_id);
     return \Redirect::to('/ManageCategories');
 }