sebastienheyd / boilerplate

Laravel AdminLTE 3 Boilerplate package with blade components, users, roles and permissions management
MIT License
221 stars 66 forks source link

ID issue in Datatables class #79

Closed thracefields closed 1 year ago

thracefields commented 1 year ago

If we have for example UsersDatatable.php, but the first column is from relationship - for example books, in the buttons as last field it will return the book id for route, not the user id. I think that it must be the model it uses as id source and ther order of the columns doesn't have to matter.

sebastienheyd commented 1 year ago

Take this file as an example : https://github.com/sebastienheyd/boilerplate/blob/master/src/Datatables/Admin/UsersDatatable.php

As you can see at line 19, I get the roles with the users. You have to do the same with books in your example.

After that, use the method data() to show the books name for example, see line 81

At last, only the main model is used for buttons, see line 103. If not, your datasource method certainly returns books instead of users.