Livewire wire:model 不适用于嵌套组件

Livewire wire:model not working with nested components

我正在使用 livewire 创建一个页面来列出来自数据库的用户并能够更新他们.. 我有一个用户父组件和(用户)子组件

users.blade.php:

<div>
    @foreach($users as $key => $user)
        <livewire:user :user="$user" key="{{$user->id}}">
    @endforeach
</div>

user.blade.php

<div>
    <form wire:submit.prevent="save">
        <input type="text" wire:model="user.name">
        <input type="text" wire:model="user.email">
        <button class="btn btn-info" type="submit">Save</button>
    </form>
</div>

Users.php

class Users extends Component
{
    public $users;
    
    public function mount()
    {
        $this->users = User::all();
    }

    public function render()
    {
        return view('livewire.users');
    }
}

User.php

class User extends Component
{
    public $user;

    public function mount(\App\Models\User $user)
    {
        $this->user = $user;
    }

    public function render()
    {
        return view('livewire.user');
    }

    protected $rules = [
        'name' => 'required|min:6',
        'email' => 'required|email',
    ];

    public function save()
    {
        $this->validate();
        $user = $this->user;
        User::find($user['id'])->fill([
            'name' => $user['name'],
            'email' => $user['email']
        ]);
    }
}

这是我在浏览器中得到的

知道为什么会这样吗?

我发现了问题,是验证规则,我不得不将其更改为

protected $rules = [
    'user.name' => 'required|min:6',
    'user.email' => 'required|email',
];