Advertisement
Guest User

Untitled

a guest
Nov 30th, 2017
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. <?php
  2. namespace App\Http\Controllers;
  3. use Illuminate\Http\Request;
  4. use App\User;
  5. class RegisterController extends Controller {
  6. public function index() {
  7. return view('front/register');
  8. }
  9.  
  10.  
  11. public function VerifyPass(string $pass1, string $pass2) {
  12. if ($pass1 === $pass2) {
  13. return true;
  14. }
  15. }
  16.  
  17. public function UsersExists(string $email) {
  18. $user = User::where('email', $email)->get();
  19. if (count($user) <= 0) {
  20. return true;
  21. }
  22. }
  23.  
  24.  
  25.  
  26. public function register(Request $post) {
  27.  
  28. if ($post->has('name') AND $post->has('last') AND $post->has('email') AND $post->has('pass1') AND $post->has('pass2')) {
  29.  
  30. if (!$this->UsersExists($post->input('email'))) {
  31. $array['exists'] = 'o usuario existe';
  32. }
  33.  
  34. if (!$this->VerifyPass($post->input('pass1'), $post->input('pass2'))) {
  35. $array['pass'] = 'as senhas são diferentes';
  36. }
  37.  
  38. if (empty($array['pass']) AND empty($array['exists'])) {
  39.  
  40. $Register = new User;
  41.  
  42. $Register->name = $post->input('name');
  43.  
  44. $Register->last = $post->input('last');
  45.  
  46. $Register->email = $post->input('email');
  47.  
  48. $Register->password = bcrypt($post->input('pass1'));
  49.  
  50. $Register->save();
  51.  
  52. } else {
  53. return view('front/register', $array);
  54. }
  55.  
  56. } else {
  57.  
  58. return redirect('register');
  59. }
  60.  
  61. }
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement