Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

ad45's avatar
Level 1

Eloquent model does not persist between Livewire updates

Livewire component does not track Eloquent model between updates. Super simple example below:

TestComponent.php

<?php

namespace App\Livewire;

use App\Models\Individual;
use Livewire\Component;

class TestComponent extends Component
{
    public Individual $individual;

    public function mount() {
        $this->individual = new Individual();
        $this->individual->first_name = 'joe';
        $this->individual->last_name = 'schmoe';
    }

    public function updateFunction() {
        // Do Nothing
    }

    public function render()
    {
        return view('livewire.test-component');
    }
}

test-component.blade.php

<div>
    <div>{{ $this->individual->first_name }}</div>
    <button wire:click="updateFunction()">Click me</button>
</div>

On first render, the name, 'joe', is displayed. After clicking on the button, the name disappears because $individual->first_name is wiped. When I get the class of $individual, it's still shows an Eloquent model.

This is weird, because https://livewire.laravel.com/docs/properties#supported-property-types says that Illuminate\Database\Eloquent\Model is a supported property type.

Help please!

0 likes
3 replies
Snapey's avatar
Snapey
Best Answer
Level 122

its not weird because the model is fetched from the database on each render

1 like
ad45's avatar
Level 1

@Snapey thanks, do you know where I can find where it says that, or did you just go through the source?

valentin_vranic's avatar

It does not throw you an error, the $this->individual->first_name? You have to use $this on computed properties

Please or to participate in this conversation.