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

FCNahian's avatar

How to send pagination link to laravel/livewire nested component?

I have built a table component in livewire. I can pass all the parameters from my main model component to the table component and everything works fine except the pagination links.

Here is the error

Property type not supported in Livewire for property: [{"current_page":1,"data":[{"id":27,....... .......}],"first_page_url":"http://localhost:8000/employees?employee_page=1","from":1,"last_page":2,"last_page_url":"http://localhost:8000/employees?employee_page=2","links":[{"url":null,"label":"« Previous","active":false},{"url":"http://localhost:8000/employees?employee_page=1","label":"1","active":true},{"url":"http://localhost:8000/employees?employee_page=2","label":"2","active":false},{"url":"http://localhost:8000/employees?employee_page=2","label":"Next »","active":false}],"next_page_url":"http://localhost:8000/employees?employee_page=2","path":"http://localhost:8000/employees","per_page":20,"prev_page_url":null,"to":20,"total":27}]

Here is my code in main component:

 @livewire('includes.dynamicdatatable.table', [
                            'table' => $table,
                            'table_tabs_buttons' => $this->table_tabs_buttons,
                            'table_filter_rows' => $this->table_filter_rows,
                            'table_rows' => $this->table_rows,
                            'table_pagination_infos' => $this->tablePaginationInfos,
                            'model' => $this->employees,
                        ])

This is the code in nested component:

<div class="col-4">
            {{ $this->model->links() }}
</div>

This is the code in nested component mount method:

public function mount($table, $table_tabs_buttons, $table_filter_rows, $table_rows, $table_pagination_infos, $model)
    {
        $this->initial_table = $table;
        $this->table = $table;
        $this->table_tabs_buttons = $table_tabs_buttons;
        $this->table_filter_rows = $table_filter_rows;
        $this->table_rows = $table_rows;
        $this->table_pagination_infos = $table_pagination_infos;
        $this->model = $model;
    }

How can i pass the pagination links to my nested component properly?

0 likes
1 reply
Chingy's avatar

If you are passing an array as a param to a component, you need to make sure the items don't have anything else than primitive types as values. (Collection etc)

Btw, using WithPagination trait in Livewire, it comes with some default behaviour. Perhaps for simplifying your code and not bloating, you can use that trait and its properties ?

Please or to participate in this conversation.