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

bennajah's avatar

`Property type not supported in Livewire for property

Error: Property type not supported in Livewire for property: [{"current_page":1,"data":[{"id":1,"name":"Alf.....

<?php

namespace App\Livewire;

use App\Models\Product;
use Livewire\Component;
use Livewire\WithPagination;

class ProductList extends Component
{
    use WithPagination;
    public $products;

    public function mount()
    {
        $this->products = Product::paginate(5);
    }

    public function render()
    {
        return view('livewire.product-list');
    }
}

product-list.blade.php

<div>
    @foreach ($products as $product)
        <div>
            {{ $product->name }}
        </div>
    @endforeach
    {{ $products->links() }}
</div>
0 likes
4 replies
Snapey's avatar

really bad idea to set a collection of products as a public property, even if it was possible

pass the products to the view as you would any view

<?php

namespace App\Livewire;

use App\Models\Product;
use Livewire\Component;
use Livewire\WithPagination;

class ProductList extends Component
{
    use WithPagination;

    public function render()
    {
        $products = Product::paginate(5);

        return view('livewire.product-list', compact('products'));
    }
}
7 likes
VadimB's avatar

@Deveasey In your example, you're trying to store the paginated results in a public property. This approach leads to issues due to the following:

  • 1 Serialization of Complex Objects: Livewire attempts to serialize all public properties to keep the component's state consistent across requests. However, a paginated Eloquent collection is a complex object that includes not just the items but also meta-information about pagination (like current page, total pages, etc.). Serializing such complex structures can lead to errors, as you've encountered.

  • 2 Lifecycle Hook Timing: The mount() method is only called once when the component is initially rendered. If you try to store paginated results in a public property within mount(), you're not accounting for subsequent updates that might occur due to pagination actions (like moving to a different page). This static approach doesn't work well with the dynamic nature of pagination.

  • 3 Incompatibility with Livewire's Reactivity: Storing paginated results in a public property interferes with Livewire's reactivity model. Since Livewire relies on the difference in property values to determine what needs to be updated on the front end, complex objects like paginated results can lead to unexpected behaviors or errors.

8 likes
Fratello's avatar

public function render() { $this->category = Category::pluck('id','name');

    $products = product::orderBy('id','asc')->paginate(3);


    return view('livewire.product-crud', compact('products')
   )
    ->layout('layouts.dashboard.master');
}
1 like

Please or to participate in this conversation.