vendredi 14 février 2020

How to properly create a sign up and a sign in form on laravel 6 on the same page?

I have a form on my front_page for logging in and signing up on the same page. The forms are:

{!! Form::open(['route' => 'auth.login']) !!}
{!! Form::email('email', $value = null, ['class' => 'form-control signup_field', 'placeholder' => 'Email Address']) !!}
{!! Form::password('password', ['class' => 'form-control signup_field', 'required', 'placeholder' => 'Password']) !!}
{!! Form::submit('Sign in', ['class' => 'btn sign_up_btn']) !!}
{!! csrf_field() !!}
{!! Form::close() !!}

{!! Form::open(['route' => 'auth.register']) !!}
            <div class="row signup_form">
                <div class="col-md-3">
                    {!! Form::email('email', $value = null, ['class' => 'form-control signup_field', 'placeholder' => 'Email Address']) !!}
                </div>
                <div class="col-md-3">
                    {!! Form::password('password', ['class' => 'form-control signup_field', 'required', 'placeholder' => 'Password']) !!}
                </div>
                <div class="col-md-3">
                    {!! Form::email('paypal_email', $value = null, ['class' => 'form-control signup_field', 'placeholder' => 'Paypal Email Adress']) !!}
                </div>
                <div class="col-md-3">
                    {!! Form::submit('Sign up', ['class' => 'btn sign_up_btn']) !!}
                </div>
            </div>
            @if($errors->any())
                @foreach($errors->all() as $error)
                    <div class="alert alert-danger">
                        <strong>Error!</strong> 
                    </div>
                @endforeach
            @endif
            {!! csrf_field() !!}
            {!! Form::close() !!}

My routes file:

Route::post('/', 'Auth\RegisterController@create')->name('auth.register');
Route::post('/', 'Auth\LoginController@login')->name('auth.login');

RegisterController@create:

public function create(Request $request) {
    $create = User::create([
        'email' => $request['email'],
        'paypal_email' => $request['paypal_email'],
        'password' => Hash::make($request['password']),
    ]);
    if($create){
        return redirect('/home');
    }
}

LoginController@login;

How to define it properly?

So the question is, how to properly define my routes file, RegisterController@create method and LoginController@login method? I saw a lot of information how to fix those forms, so the main questions are these.



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2uB9pHS
via IFTTT

Aucun commentaire:

Enregistrer un commentaire