Using Tabels without eloquent Models #2283
-
I have data which comes from other sources than a database in my application. Is there a way to show that data without an eloquent model? So far, I tried overriding class ExportExcel extends BaseWidget
{
protected function getTableQuery(): Builder
{
return Participant::query();
}
public function getTableRecords(): Collection|Paginator
{
/** @var Participants $participantExporter */
$participantExporter = resolve(Participants::class);
return Collection::make(collect($participantExporter->getExportedFiles())
->map(function ($d) {
return new class extends Model {
public function getAttributes()
{
return ['name', 'date'];
}
};
}));
}
protected function getTableColumns(): array
{
return [
Tables\Columns\TextColumn::make('name')
->label('Export'),
Tables\Columns\TextColumn::make('date')
->label('Erstellt'),
];
}
} My attempt does not feel like it should work or is an intended way to go about this, therefore I didn't try to make it work. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 4 replies
-
So it could be use with a custom SQL query in the getRows() method, then used as an eloquent model. If it works, it's really a good thing ! |
Beta Was this translation helpful? Give feedback.
-
I have an application where I'm displaying a table with data fetched from an API using the Sushi package. When a user selects a record from this table, I want to open another table in a modal (or new page). This new table should fetch data from a different API, and this time, I'm not using the Sushi package. The data for the second table should be based on the values from the selected record in the initial table. Can Somebody Help me for above query ? |
Beta Was this translation helpful? Give feedback.
https://github.com/calebporzio/sushi