My Blade file code is like below.
<form action="{{ route('login') }}" method="post" class="row mt-4 align-items-center">
<input type="hidden" name="_token" value="{{ csrf_token() }}">
<div class="mb-3 col-sm-12">
<label class="form-label">Email Address <span class="text-danger">*</span></label>
<input type="email" name="email" class="form-control" placeholder="Enter your email">
</div>
<div class="mb-3 col-sm-12">
<label class="form-label">Password <span class="text-danger">*</span></label>
<input type="password" name="password" class="form-control" placeholder="Enter your password">
</div>
<div class="mb-3 col-sm-12">
<div class="form-group custom-checkbox" title="{{ __('Remember Me') }}">
<input type="checkbox" id="rememberMe" name="remember" value="1">
<label class="fw-normal" for="rememberMe">{{ __('Remember Me') }}</label>
</div>
</div>
<div class="mt-3col-sm-6 d-grid">
<button type="submit" class="btn btn-primary">Sign In</button>
</div>
</form>
According to blade file there will be a route like below in routes/web.php
file.
Route::post('login', [])->name('');
But I am not getting any login route like above in routes/web.php
file.
Where is the controller of this Form
where it is submitting ?
How it is redirecting ?
2
Answers
To define the form action with a Laravel web route, you define the route in your routes/web.php like this:
LoginController
generating URLs or redirects using the route’s name.
One more suggestion: regarding to csrf token:
Instead of manual input type hidden for csrf, you can use built-in feature for csrf as follows:
use below command in terminal to get all your laravel routes based on their name,this will help you to find all routes
and look it up for the route named "login" and then its controller will be found easily