livewire-datatables
livewire-datatables copied to clipboard
Column::callback(): Argument #1 ($columns) must be of type string, array given
In src/Column.php:118
you set the type to "string" when it should be Array|String
Raised a PR to fix it: https://github.com/MedicOneSystems/livewire-datatables/pull/428
The problem with this merge is, that's it's not working with PHP 7 anymore.
Sure that PHP7 is not able to do type hint?
I think not. Am I correct? https://www.php.net/manual/de/language.types.declarations.php#language.types.declarations.composite.union
Could be a solution to drop the type declarations?
I had this same issue, I was using a string to make the names unique. I changed the string to a dummy array value. Seems like a better solution would be to use the label with generating the internal callback name.
Column::callback(['aqua_camp_weeks.id'], function($id) {
return ('<a href="'. route('add-camper-to-session', ["id" => $id]) .'"
class="p-1 text-blue-600 hover:bg-blue-600 hover:text-white rounded">
Add Child </a>');
}**,['a']**) //array ['a'] at end is required since the callback is id all the callback functions have the same name
->label('Add Child')
->unsortable()
->excludeFromExport(),
Column::callback(['aqua_camp_weeks.id'], function($id) {
return $this->weekStatus[$id];
},**['b']**)
->unsortable()
->label('Week Status'),