@Kyber_Ded

Почему выдает 302 редирект?

Добрый вечер всем. Сразу говорю. Учусь на недопиленом проекте.
Есть форма. Вроде все присутствует, включая @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\PhysRegisterController@create')->name('register.phys');


61aa2f9e1651a865250300.png

Все вроде уходит, но var_dump в экшне не срабатывает и возвращается 302 редирект. Причем на всех запросах типа пост

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');
    }


Объясните падавану, почему такое творится и как наладить ситуацию
  • Вопрос задан
  • 78 просмотров
Решения вопроса 1
@exezio
Редиректит скорее всего PhysRegisterRequest, смотри в нем метод rules. Если какое то поле отправляемое формой невалидно, то выполняется редирект на тот же роут, с которого улетел запрос. Так же внимательно с неймами формы, нужно чтобы они совпадали с теми, что в Request, а так же просмотри правила валидации в том же Request.
Ответ написан
Комментировать
Пригласить эксперта
Ответы на вопрос 1
Fragster
@Fragster
помогло? отметь решением!
Используй вместо var_dump dd, а лучше - один раз заставь себя настроить xdebug
Ответ написан
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы