'Can't update data in CRUD Laravel 8: ERROR: Ensure that the [name, id, data] of the Livewire component wasn't tampered with between requests

I want to update my CRUD App, but it always give me an error

this is the error

Livewire encountered corrupt data when trying to hydrate the [crud.edit-student- 
component] component. Ensure that the [name, id, data] of the Livewire component wasn't  

tampered with between requests.

so how to update the data when it change?

my code just give the error message like ADD NEW data, it's the same way as well

this is my code in the function:

public function mount($id)
{
    $student= Student::where('id', $id)->first();
    $this->fill([
        'student_id' => $student->student_id,
        'name' => $student->name,
        'email' => $student->email,
        'phone' => $student->phone,
    ]);
}

public function updatestudent()
{
    $this->update([

        $this->student_id = '',
        $this->name = '',
        $this->email = '',
        $this->phone = '',
    ]);

    $this->validate([
        'student_id' => 'required|unique:students',
        'name' => '',
        'email' => '|email|unique:students,email' ,
        'phone' => '|numeric|unique:students,phone',
        
    ]);

    $student = Student::where('id', $this->student_edit_id)->firts();

    $student -> student_id = $this->student_id;
    $student -> name = $this->name;
    $student -> email = $this->email;
    $student -> phone = $this->phone;
    dd($student);
    $student-> save();

    session()->flash('message', 'Student has been updated successfully');

    $this->student_id = '';
    $this->name = '';
    $this->email = '';
    $this->phone = '';
}

this is my code in blade file:

   <form wire:submit.prevent="updatestudent">
   <div class="form-group">
   <label for="student_id">Student ID</label>
   <input type="number" class="form-control" wire:model="student_id"/>

hopefully you help me Sir, thank's



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source