livewire-datatables
livewire-datatables copied to clipboard
Pass relationship column to callback
Hello!, when i try pass a relationship variable in a callback i get an error (example roles.name), but in a simple column works fine
Refer to the Relation example.
So, in the columns method, you can write Column::callback(['roles.name'], closure()), and at the bottom of the file (or anywhere) add the getRolesProperty() method.
Example code:
public function columns()
{
return [
Column::callback(['roles.name']), function($role_name) {
return $role_name;
}),
];
}
public function getRolesProperty()
{
Roles::all();
}
Tell me if you have any issues.