Reputation: 55
So I made a form page that should direct its input values into a registration page from laravel, but controller is not redirecting to the register page after the form is filled and sent,
<?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']
]);
}
}
Here is the form method in the invites.blade.php
<div class="card-body">
<form method="POST" action="{{ route('register') }}">
@csrf
and the route in web.php
Auth::routes();
Route::get('/invite', 'InviteController@index')->name('invite');
and this is the route service provider I entered.
/**
* The path to the "home" route for your application.
*
* @var string
*/
public const HOME = '/home';
public const REGISTER = '/register';
Upvotes: 1
Views: 242
Reputation: 5270
You have to use like this
<form method="POST" action="{{ route('invite') }}">
And your routes/web.php
use like this
Route::post('/your_url_name', 'InviteController@your_function_name')->name('invite');
Upvotes: 1