我如何在laravel中显示通过路线和控制器的模态?

问题描述 投票:0回答:1

所以,我想使用模式创建登录表单。我一直在寻找一个解决方案,但我仍然感到困惑(因为所有的解决方案都用英语,而我的英语不是很好)。而且不知道解决方案的代码是如何工作的。因此,也许有人可以通过修复我的代码行并向我解释其工作原理来帮助我?请吗?

这是我的包含模态的文件

<!-- Modal Login-->
    <div class="modal fade" id="loginForm" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog" role="document">
        <!--Content-->
            <div class="modal-content form-elegant">
                <!--Header-->
                <div class="text-center">
                    <h3 class="modal-title w-100 dark-grey-text font-weight-bold mt-5" id="myModalLabel"><strong>Login</strong></h3>
                </div>
                <!--Body-->
                <div class="modal-body mx-4">
                    <!--Body-->
                    <form class="form" method="POST" action="#">
                        {{ csrf_field() }}
                        <div class="md-form">
                            <input type="email" name="email" id="inputEmail" placeholder="Email" required="@" autofocus>
                        </div>

                        <div class="md-form">
                            <input type="password" name="pass" id="inputPass" placeholder="Password" required>
                        </div>

                        <input type="submit" class="logbtn" value="Login">
                        <input type="button" data-dismiss="modal" class="cancelbtn" value="Cancel">
                    </form>
                </div>
                <!--Footer-->
                <div class="modal-footer mx-5 pt-3 mb-1">
                    <p class="font-small grey-text d-flex justify-content-end">
                        Don't have an account? <a href="#" class="blue-text ml-1" data-dismiss="modal" data-toggle="modal" data-target="#registerForm">Sign Up</a>
                    </p>
                </div>
            </div>
        <!--/.Content-->
        </div>
    </div>
    <!-- Modal Login-->

    <!-- Modal Register-->
    <div class="modal fade" id="registerForm" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog" role="document">
        <!--Content-->
            <div class="modal-content form-elegant">
                <!--Header-->
                <div class="text-center">
                    <h3 class="modal-title w-100 dark-grey-text font-weight-bold mt-5" id="myModalLabel"><strong>Register</strong></h3>
                </div>
                <!--Body-->
                <div class="modal-body mx-4">
                    <!--Body-->
                    <form class="form" method="POST" action="#">
                        {{ csrf_field() }}
                        <div class="md-form">
                            <input type="text" name="name" id="inputName" placeholder="Name" required autofocus>
                        </div>

                        <div class="md-form">
                            <input type="email" name="email" id="inputEmail" placeholder="Email" required="@">
                        </div>

                        <div class="md-form">
                            <input type="password" name="pass" id="inputPass" placeholder="Password" required>
                        </div>

                        <div class="md-form">
                            <input type="password" name="pass_conf" id="inputPassConf" placeholder="Password Confirmation" required>
                        </div>

                        <input type="submit" class="logbtn" value="Register">
                        <input type="button" data-dismiss="modal" class="cancelbtn" value="Cancel">
                    </form>
                </div>
                <!--Footer-->
                <div class="modal-footer mx-5 pt-3 mb-1">
                    <p class="font-small grey-text d-flex justify-content-end">
                        Already have an account? <a href="#" class="blue-text ml-1" data-dismiss="modal" data-toggle="modal" data-target="#loginForm">Login</a>
                    </p>
                </div>
            </div>
        <!--/.Content-->
        </div>
    </div>
    <!-- Modal Register-->

这是我的控制器(我不知道该做什么)

class AuthController extends Controller
{
    public function login() {
        //
    }

    public function postLogin(Request $request) {
        //
    }

    public function postRegister(Request $request) {
        //
    }
}

这是我的路线(这条路线还是错误的)

Route::get('/login' , 'AuthController@login');
Route::post('/', 'AuthController@postLogin');
Route::post('/', 'AuthController@postRegister');

感谢您的时间!

php laravel controller routes modal-dialog
1个回答
0
投票

您可以使用Laravel's built-in authentication system

在Laraval 5.8中:

php artisan make:auth

使用6.0参见https://stackoverflow.com/a/57790856/10558454

© www.soinside.com 2019 - 2024. All rights reserved.