Ibakha
Ibakha
FFilament
Created by Ibakha on 1/13/2025 in #❓┊help
Table actions returning the wrong records
I'm making a table for users to see the messages they're allowed to check. It only has a view action. The project uses livewire components instead of filament panels. I already have multiple tables with custom queries, but this one is the first to cause this issue. The query is getting the records respecting the conditions as it should. So at first glance, the table seems fine, but no matter which action I try (view, edit, delete) of any record, the action always gets the same record. If I remove the query conditions to recover all the records or only keep one condition, the actions recover the right records. Depending on which conditions I keep, there are some cases where the first two of the table will be fine, but the rest will get one of the first two. The issue is before getting the infolist, I'm having the same reaction if I dd the record instead of the infolist or a form. Has anyone encountered something similar?
9 replies
FFilament
Created by Ibakha on 10/31/2024 in #❓┊help
Get Table Record in Livewire Component
Hi, I'm using a filament table in a livewire component. I'm trying to use a record of the table to pass an argument to a view, but my record is always returning the livewire class and not the table record. I made an infolist in the ViewAction to confirm if the data I can display the information of the selected record and I'm recovering the right information, but in this case, I'm using the view of an older project and I some information from the record for the api query. Any idea? Sorry in advance if the answer is obvious, I'm relatively new to laravel. Thanks for the help! Here's what I'm getting in the record:
Closure($record) {#2221 ▼ // app/ApiWrapper.php:16
class: "App\Livewire\Stubs\ListStubs"
this: App\Livewire\Stubs\ListStubs {#1075 …}
}
Closure($record) {#2221 ▼ // app/ApiWrapper.php:16
class: "App\Livewire\Stubs\ListStubs"
this: App\Livewire\Stubs\ListStubs {#1075 …}
}
And here's my table
public function table(Table $table): Table
{
return $table
->query(Stub::query())
->columns([
// ...
])
->filters([
// ...
], layout: FiltersLayout::AboveContent)
->actions([
// dd(fn (Stub $record) => dd($record)),
ViewAction::make()
->model(Stub::class)
->view('forms.stub', ['employee' => ApiWrapper::getEmployeeStub(Auth::user()->id, fn ($record) => $record->stub_id)])
]);
}

public function table(Table $table): Table
{
return $table
->query(Stub::query())
->columns([
// ...
])
->filters([
// ...
], layout: FiltersLayout::AboveContent)
->actions([
// dd(fn (Stub $record) => dd($record)),
ViewAction::make()
->model(Stub::class)
->view('forms.stub', ['employee' => ApiWrapper::getEmployeeStub(Auth::user()->id, fn ($record) => $record->stub_id)])
]);
}

2 replies