kdion4891 / laravel-livewire-tables

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

Transform column data from model #7

Closed oliverbj closed 4 years ago

oliverbj commented 4 years ago

Hi @kdion4891

Very nice project you have created here! I was wondering, is it possible to transform the data before serving it to the table?

For example, if I have a name column, I would like to make sure that the first character is always capitalized:

public function columns()
    {
        return [
            Column::make('Name', 'first_name')->searchable()->sortable(),
        ];
    }

How can I do so I can use ucfirst('first_name') for example?

oliverbj commented 4 years ago

Nevermind, I figured out I could just use the $this->view() for this.

kdion4891 commented 4 years ago

Or use an accessor in your model...