Make Table rows unclickable

Hello friends! is there any way that I can avoid to make the table rows clickable? currently when I click, it redirects to edit page. I want to make it clickable based on conditions
9 Replies
Lambertn33
Lambertn33OP2y ago
@toeknee_iom thanks for this but should I include this in the resource file? on in the ListCampaigns? for now it is not working! I am not getting this well
toeknee
toeknee2y ago
On the ListRecords(ListCampaigns) as it's a table function. Your IDE should show you available functions to override when typing a new function in the class.
Lambertn33
Lambertn33OP2y ago
can I include a condition in this @toeknee_iom ? let's say if the $record->manager_id == Auth->user()->id that is when the row should be clickable?
toeknee
toeknee2y ago
yes, sorry I should have linked you above to https://filamentphp.com/docs/2.x/tables/getting-started#record-urls
Filament
Getting started - Table Builder - Filament
The elegant TALL stack table builder for Laravel artisans.
toeknee
toeknee2y ago
essentially just use $record->manager_id == Auth->user()->id ? 'add the url function here' : null so full code
protected function getTableRecordUrlUsing(): ?Closure
{
return fn (Model $record) => $record->manager_id == Auth->user()->id ? route('posts.edit', ['record' => $record]) : null;
}
protected function getTableRecordUrlUsing(): ?Closure
{
return fn (Model $record) => $record->manager_id == Auth->user()->id ? route('posts.edit', ['record' => $record]) : null;
}
should work
Lambertn33
Lambertn33OP2y ago
I am getting this Return value must be of type string, null returned return fn (Campaign $record): string => Auth::user()->role->role !== Role::DISTRICT_MANAGER_ROLE ? null : ( $record->manager_id == Auth::user()->manager->id ? route('filament.resources.campaigns.edit', ['record' => $record]) : null );
toeknee
toeknee2y ago
updated
Lambertn33
Lambertn33OP2y ago
Thank you so much @toeknee_iom it is working now!
Want results from more Discord servers?
Add your server