Answer the question
In order to leave comments, you need to log in
Why is it giving a 302 redirect?
Good evening everyone. I say right away. I'm learning from an unfinished project.
There is a form. Everything seems to be present, including @crsv
<form id="phys_form" class="rdj-validate-form" method="POST" autocomplete="off" novalidate="novalidate" action="{{ route('register.phys') }}">
@csrf
<input type="hidden" name="form_type" value="phys">
@include('auth.partials.fio_block', ['firstname_ph' => __('Имя'), 'lastname_ph' => __('Фамилия'), 'fathername_ph' => __('Отчество')])
<label class="field-text">
<span class="field-text__input-wrap input-field">
<label class="pineput-label">Город</label>
<input class="pineput-input field-text__input{{ $errors->has('city') ? ' __rds_incorrect' : '' }}"
type="text"
-placeholder="Город"
-title="Город"
name="city"
value="{{ old('city') }}"
-data-rd_required3-inputmask
-required
>
@if ($errors->has('city'))
<span class="field-text__help-text __rds_red_color" role="alert">
{{ $errors->first('city') }}
</span>
@endif
</span>
</label>
@include('auth.partials.phone_n_email_block')
@include('auth.partials.password_block', ['type' => 'phys'])
@include('auth.partials.reg_n_agree_block', ['type' => 'phys'])
</form>
Auth::routes(['verify' => true]);
Route::redirect('/home', '/');
Route::post('/register-phys', 'Auth\[email protected]')->name('register.phys');
public function create(PhysRegisterRequest $request) {
var_dump(123);exit;
$user = User::create([
'name' => $request->lastname .' '. $request->firstname .' '. $request->fathername,
'phone' => $request->phone,
'email' => $request->email,
'role' => User::ROLE_PHYS,
'password' => bcrypt($request->password),
]);
$user->sendEmailVerificationNotification();
UsersPhysProfile::create([
'user_id' => $user->id,
'company_identify' => $request->lastname .' '. $request->firstname .' '. $request->fathername,
'lastname' => $request->lastname,
'firstname' => $request->firstname,
'fathername' => $request->fathername,
'phone_number' => $request->phone,
'city' => $request->city,
]);
Auth::loginUsingId($user->id);
return redirect('account');
}
Answer the question
In order to leave comments, you need to log in
The redirect is most likely a PhysRegisterRequest, see the rules method in it. If some field sent by the form is invalid, then a redirect is performed to the same route from which the request originated. Just be careful with the form names, you need them to match those in the Request, and also look at the validation rules in the same Request.
Use dd instead of var_dump , or better yet, force yourself to set up xdebug once
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question