Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace App\Http\Controllers;
- use Illuminate\Http\Request;
- use App\User;
- class RegisterController extends Controller {
- public function index() {
- return view('front/register');
- }
- public function VerifyPass(string $pass1, string $pass2) {
- if ($pass1 === $pass2) {
- return true;
- }
- }
- public function UsersExists(string $email) {
- $user = User::where('email', $email)->get();
- if (count($user) <= 0) {
- return true;
- }
- }
- public function register(Request $post) {
- if ($post->has('name') AND $post->has('last') AND $post->has('email') AND $post->has('pass1') AND $post->has('pass2')) {
- if (!$this->UsersExists($post->input('email'))) {
- $array['exists'] = 'o usuario existe';
- }
- if (!$this->VerifyPass($post->input('pass1'), $post->input('pass2'))) {
- $array['pass'] = 'as senhas são diferentes';
- }
- if (empty($array['pass']) AND empty($array['exists'])) {
- $Register = new User;
- $Register->name = $post->input('name');
- $Register->last = $post->input('last');
- $Register->email = $post->input('email');
- $Register->password = bcrypt($post->input('pass1'));
- $Register->save();
- } else {
- return view('front/register', $array);
- }
- } else {
- return redirect('register');
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement