kdion4891 / laravel-livewire-tables

A dynamic, responsive Laravel Livewire table component with searching, sorting, checkboxes, and pagination.
302 stars 41 forks source link

Bug: Sorting by relation column replaces model original data with relation data #11

Closed fahmifitu closed 4 years ago

fahmifitu commented 4 years ago

Bank: id name country_id

Country: id name

Sorting by Country name breaks the data in table and loads data of country into bank columns that has the same name (eg: id, name, created_at, updated_at, etc..)

kdion4891 commented 4 years ago

have you set up the relationships in the models?

in the column declaration, you'd use something like country.name, notice the period. please see the docs.

kdion4891 commented 4 years ago

You also may need to use ->select('banks.*') on your query.

fahmifitu commented 4 years ago

->select('banks.*')

This did the trick! Thanks for the response.