因此,我制作了一个表单页面,该页面应将其输入值从 laravel 定向到注册页面,但在填写并发送表单后,控制器不会重定向到注册页面,<?phpnamespace 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');
1 回答
慕桂英546537
TA贡献1848条经验 获得超10个赞
你必须像这样使用
<form method="POST" action="{{ route('invite') }}">
而你的routes/web.php
使用是这样的
Route::post('/your_url_name', 'InviteController@your_function_name')->name('invite');
- 1 回答
- 0 关注
- 89 浏览
添加回答
举报
0/150
提交
取消