How can I get table data in trait?
table->getRecords() gets the database data.
This is not enough for me because I show the data in the table by formatting it. Is there any way to get the fully formatted data in the table?
@Sinnbeck
For example, movement_type value comes IN with db. I show the value that matches the FormatStateUsing enum in the table. When I get the records as I mentioned, it will be necessary to redefine this and similar formats for each column. And I am trying to write a triad for many tables because I need a dynamic structure. So I need to get what is in the table as it is.
Incoming “CASH_IN” value is converted to “Cash In” with formatStateUsing.
trait PdfExport { public function exportToPdf() { $data = $this->table->getRecords(); dd($data); .... } }
When I get the table records here, the data comes with the value “CASH_IN”, not “Cash In”. getRecords brings the records in their original form. Is there any way to get the transformed data in the table? This is exactly my question.
@rmznatly
you can mutate it in the model,
you can also map using the map method after you get the data from the query,
you can also try using a Resource class