猿问

表单页面未重定向到 Laravel 中所需的页面

因此,我制作了一个表单页面,该页面应将其输入值从 laravel 定向到注册页面,但在填写并发送表单后,控制器不会重定向到注册页面,


<?php


namespace App\Http\Controllers;


use App\Providers\RouteServiceProvider;

use Illuminate\Foundation\Auth\RegistersUsers;

use Illuminate\Http\Request;

use Illuminate\Support\Facades\Validator;

use App\Http\Controllers\Controller;

use App\User;

use Illuminate\Support\Facades\Hash;



class InviteController extends Controller

{

    /*

    |--------------------------------------------------------------------------

    | Register Controller

    |--------------------------------------------------------------------------

    |

    | This controller handles the registration of new users as well as their

    | validation and creation. By default this controller uses a trait to

    | provide this functionality without requiring any additional code.

    |

    */

    /**

     * Show the application dashboard.

     *

     * @return \Illuminate\Contracts\Support\Renderable

     */

    public function index()

    {

        return view('invite');

    }  //


    

    /**

     * Where to redirect users after registration.

     *

     * @var string

     */

    protected $redirectTo =  RouteServiceProvider::REGISTER;


    /**

     * Create a new controller instance.

     *

     * @return void

     */

    public function __construct()

    {

        $this->middleware('guest');

    }


    /**

     * Get a validator for an incoming registration request.

     *

     * @param  array  $data

     * @return \Illuminate\Contracts\Validation\Validator

     */

    protected function validator(array $data)

    {

        return Validator::make($data, [



            'username' => ['required', 'string', 'max:255', 'unique:users']



        ]);

    }



}

这是invites.blade.php中的表单方法


                <div class="card-body">

                    <form method="POST" action="{{ route('register') }}">

                        @csrf


以及 web.php 中的路由


Auth::routes();


Route::get('/invite', 'InviteController@index')->name('invite');

森林海
浏览 90回答 1
1回答

慕桂英546537

你必须像这样使用<form&nbsp;method="POST"&nbsp;action="{{&nbsp;route('invite')&nbsp;}}">而你的routes/web.php使用是这样的Route::post('/your_url_name',&nbsp;'InviteController@your_function_name')->name('invite');
随时随地看视频慕课网APP
我要回答