PHP内部动态重定向

Today I have so troublemaking question for you.

I'm preparing with my group project in PHP Laravel and actually we are ending front-end. In my imagination our main 'welcome' page should look like:

Login  |  Register (dinamically changing with id accordion + collapse)

Then if clicked Login - we get Login & Password to Log in
And if clicked Register - we get panel for register into site.

My question is - how to make it with nice dynamic changes, because actually I have:

<div id="accordion">
    <ul class="nav justify-content-center">
        <div class="card text-center p-3" style="width: 40rem">
            <p>
                <a class="btn btn-primary" data-toggle="collapse" data-target="#collapseLogin" href="#collapseLogin" role="button" aria-expanded="false" aria-controls="collapseLogin">
                    Login
                </a>
                <a class="btn btn-primary" data-toggle="collapse" data-target="#collapseRegister" href="#collapseRegister" role="button" aria-expanded="false" aria-controls="collapseRegister">
                    Register
                </a>
            </p>

            <div class="collapse" id="collapseLogin" aria-labelledby="collapseLogin" data-parent="#accordion">
                <div class="card card-body">
                    <a class="nav-link" href="{{ route('login') }}">{{ __('Login') }}</a>
                </div>
            </div>
            <div class="collapse" id="collapseRegister" aria-labelledby="collapseRegister" data-parent="#accordion">
                <div class="card card-body">
                    <a class="nav-link" href="{{ route('register') }}">{{ __('Register') }}</a>
                </div>
            </div>
        </div>
    </ul>
</div>

...and it redirect by href page.

Anybody could help me with this problem? Thanks!

If you want to precise the question: How to change

<a class="nav-link" href="{{ route('register') }}">{{ __('Register') }}</a>

to get the register form (from register.blade.php) and not link to the site.

hi if i understanded correctly you want to replace link with your form, if so then you can do this .

        <div class="collapse" id="collapseLogin" aria-labelledby="collapseLogin" data-parent="#accordion">
            <div class="card card-body">
                @include('auth/login')
            </div>
        </div>

and then go to resources/views/auth/login.blade.php and make correct changes (for example delete @extends and so on.. just keep < form > .... < / form > . if u want easier solution try this

<div class="collapse" id="collapseLogin" aria-labelledby="collapseLogin" data-parent="#accordion">
            <div class="card card-body">

                <form method="POST" action="{{ route('login') }}" aria-label="{{ __('Login') }}">
                    @csrf

                    <div class="form-group row">
                        <label for="email" class="col-sm-4 col-form-label text-md-right">{{ __('E-Mail Address') }}</label>

                        <div class="col-md-6">
                            <input id="email" type="email" class="form-control{{ $errors->has('email') ? ' is-invalid' : '' }}" name="email" value="{{ old('email') }}" required autofocus>

                            @if ($errors->has('email'))
                                <span class="invalid-feedback" role="alert">
                                    <strong>{{ $errors->first('email') }}</strong>
                                </span>
                            @endif
                        </div>
                    </div>

                    <div class="form-group row">
                        <label for="password" class="col-md-4 col-form-label text-md-right">{{ __('Password') }}</label>

                        <div class="col-md-6">
                            <input id="password" type="password" class="form-control{{ $errors->has('password') ? ' is-invalid' : '' }}" name="password" required>

                            @if ($errors->has('password'))
                                <span class="invalid-feedback" role="alert">
                                    <strong>{{ $errors->first('password') }}</strong>
                                </span>
                            @endif
                        </div>
                    </div>

                    <div class="form-group row">
                        <div class="col-md-6 offset-md-4">
                            <div class="form-check">
                                <input class="form-check-input" type="checkbox" name="remember" id="remember" {{ old('remember') ? 'checked' : '' }}>

                                <label class="form-check-label" for="remember">
                                    {{ __('Remember Me') }}
                                </label>
                            </div>
                        </div>
                    </div>

                    <div class="form-group row mb-0">
                        <div class="col-md-8 offset-md-4">
                            <button type="submit" class="btn btn-primary">
                                {{ __('Login') }}
                            </button>

                            <a class="btn btn-link" href="{{ route('password.request') }}">
                                {{ __('Forgot Your Password?') }}
                            </a>
                        </div>
                    </div>
                </form>

            </div>
</div>

do the same for register