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

WallyJ's avatar

Livewire component's public property must be of type: [numeric, string, array, null, or boolean]. Only protected or private properties can be set as other types because JavaScript doesn't need to access them.

I'm receiving the following error:

Livewire component's [contactshow] public property [contactnotes] must be of type: [numeric, string, array, null, or boolean]. Only protected or private properties can be set as other types because JavaScript doesn't need to access them.

I can't tell what I'm doing wrong. Here's my code:

Livewire Controller:

<?php

namespace App\Http\Livewire;

use Livewire\Component;
use App\Task;

class Contactshow extends Component
{

    public $contacts;
    public $tasktext;
    public $dealId;
    public $taskduedate;
    public $deal_id;
    public $contactnotes;

    public function mount($contacts)
    {
        $this->contacts = $contacts;
        $this->contactnotes = $this->contacts->contactnotes()->paginate();
    }

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

}

Livewire Component View:

<div class="row">
   <div class="col-md-12">
      <ul class="list-group">
         @foreach($this->contactnotes as $contactnote)
            <li class="list-group-item">
               {{$contactnote->created_at}} - {{$contactnote->contactnotetext}}
            </li>
         @endforeach
      </ul>
   </div>
</div>
0 likes
13 replies
Snapey's avatar

Are you using the latest version? Earlier versions cannot have eloquent models as public properties

WallyJ's avatar

I will double-check my version.

WallyJ's avatar

So I learned that it was an issue with my Livewire version. So I updated. Then all was well..

Then the issue came up again, so I checked the release notes for Livewire. https://github.com/livewire/livewire/releases

It became an issue again so Caleb fixed it again in release 1.0.9.

So I updated Livewire again.

Now I still get the error message. :(

Snapey's avatar

Do you really need to make the collection a public property?

You can pass the collection to the view as you would with regular views, using compact or with()

WallyJ's avatar

I need to call it separately because I am going to paginate the results. Plus, it worked before.

Snapey's avatar

You can still paginate the results passing it in the render function.

WallyJ's avatar

I understand that I can still paginate, but even if I take the

->paginate()

out of the controller, I still get the error. The error does not have to do with pagination.

SomeOne_'s avatar

What is happening here is that Livewire is hydrating the model/object/collection via javascript if the property is public.

Currently it does only know how to hydrate Eloquent models, but not your custom models, collection and such.

So in your Livewire Compontent you have a bunch op public properties, and each of them can cause this.

What you could do is not to pass all the data in it, but use the mount() and hydrate() functions to retrieve the date you need within the component itself. And make them protected.

Edit: you could also use the Computed Properties approach: https://laravel-livewire.com/docs/properties

Snapey's avatar

pass the object to the view in the render() method, along with pagination

it does not need to be a public prop

8 likes
dskanth's avatar

Yes, it worked for me. Thanks! I am just querying and creating the pagination object and links in the render method itself, and passing both of them to view, without a public variable.

Controller:

$searchVal = '%'.$this->searchVal.'%'; return view('livewire.search',[ 'users' => User::where(DB::raw('lower(name)'), 'like', '%' . strtolower($searchVal) . '%')->orWhere(DB::raw('lower(email)'), 'like', '%' . strtolower($searchVal) . '%')->paginate(10) ]);

View:

{{ $users->onEachSide(1)->links() }}

1 like

Please or to participate in this conversation.