如何发送与Laravel Livewire收集的数据到Fortify?

问题描述

我完全不熟悉Vue.js,因此使用Livewire找到了很好的替代品。

我要解决的挑战是使用Fortify + Livewire在我的网站上进行用户友好的注册。注册过程是一个多步骤的过程,取决于用户做出的选择,它将加载相关字段。

到目前为止,我通过在FortifyServiceProvider.php文件中添加以下代码来设置Fortify视图:

Fortify::loginView(function () {
    return view('auth.login');
});

Fortify::registerView(function () {
    return view('auth.register');
});

auth/login.blade.php视图加载了livewire组件,该组件基本上是一种形式:

<form action="{{ route('register') }}" method="POST" wire:submit.prevent="submit">
    /**
    * Here would go the inputs that must be shown depends on what users choice 
    * (is it an ordinar user or a company)
    */
    <button type="submit">Save<button/>
</form>

通过将$step属性添加到Register.php类中,可以解决多格式挑战:

class RegisterForm extends Component
{
    public $step;

    public function mount()
    {
        $this->step = 0;
    }

    public function submit()
    {
        if ($this->step < 3) {
            $this->step++;           
        } else {
            // pass all the data to the fortify register method
            // <-- Here is my trouble!
        }
    }
}

,将通过每个注册步骤($this->step++)来递增。

对我来说,最重要的事情是如何防止表单提交进行验证+表单更改,最后阻止所有数据集通过Fortify注册​​过程?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)