Ibakha
Ibakha
FFilament
Created by Ibakha on 1/13/2025 in #❓┊help
Table actions returning the wrong records
Thanks! I'm not sure why it's not working in the table, but the scope is working! 😄
9 replies
FFilament
Created by Ibakha on 1/13/2025 in #❓┊help
Table actions returning the wrong records
here's the buttons, the id at the end is matching the record for each button. When clicked, it's always returning the same record in the table, example the record with id of two even if the mountTableAction as an other id in parameter
<button class="fi-link group/link relative inline-flex items-center justify-center outline-none fi-size-sm fi-link-size-sm gap-1 fi-color-gray fi-ac-action fi-ac-link-action" type="button" wire:loading.attr="disabled" wire:click="mountTableAction('view', '14')">
<button class="fi-link group/link relative inline-flex items-center justify-center outline-none fi-size-sm fi-link-size-sm gap-1 fi-color-gray fi-ac-action fi-ac-link-action" type="button" wire:loading.attr="disabled" wire:click="mountTableAction('view', '14')">
9 replies
FFilament
Created by Ibakha on 1/13/2025 in #❓┊help
Table actions returning the wrong records
all buttons have their record respective id in mountTableAction but still fetch the same record
9 replies
FFilament
Created by Ibakha on 1/13/2025 in #❓┊help
Table actions returning the wrong records
public function table(Table $table): Table
{
return $table
->query(Message::query()
->where(function ($query) {
$query->where('role', null)
->where('department_id', null)
->where('date', '<=', today());
})
->orWhere(function ($query) {
$query->where('role', null)
->whereIn('department_id', Auth::user()->departments->pluck('id'))
->where('date', '<=', today());
})
->orWhere(function ($query) {
$query->whereIn('role', Auth::user()->roles->pluck('tag'))
->where('department_id', null)
->where('date', '<=', today());
})
->orWhere(function ($query) {
$query->whereIn('role', Auth::user()->roles->pluck('tag'))
->whereIn('department_id', Auth::user()->departments->pluck('id'))
->where('date', '<=', today());
})
)
->deferLoading()
->defaultSort('updated_at', 'desc')
->defaultPaginationPageOption(10)
->paginated([10])
->columns([
Split::make([
TextColumn::make('date')
->label(__('common.date'))
->date()
->color('gray')
->grow(false),
TextColumn::make('title')
->label(__('common.title'))
->searchable()
->weight(FontWeight::Bold)
->limit(50),
])
])
->actions([
ViewAction::make()
->modalHeading(fn (Message $record) => ($record->title))
->infolist(Message::getInfolist())
->slideOver(),
]);
}
public function table(Table $table): Table
{
return $table
->query(Message::query()
->where(function ($query) {
$query->where('role', null)
->where('department_id', null)
->where('date', '<=', today());
})
->orWhere(function ($query) {
$query->where('role', null)
->whereIn('department_id', Auth::user()->departments->pluck('id'))
->where('date', '<=', today());
})
->orWhere(function ($query) {
$query->whereIn('role', Auth::user()->roles->pluck('tag'))
->where('department_id', null)
->where('date', '<=', today());
})
->orWhere(function ($query) {
$query->whereIn('role', Auth::user()->roles->pluck('tag'))
->whereIn('department_id', Auth::user()->departments->pluck('id'))
->where('date', '<=', today());
})
)
->deferLoading()
->defaultSort('updated_at', 'desc')
->defaultPaginationPageOption(10)
->paginated([10])
->columns([
Split::make([
TextColumn::make('date')
->label(__('common.date'))
->date()
->color('gray')
->grow(false),
TextColumn::make('title')
->label(__('common.title'))
->searchable()
->weight(FontWeight::Bold)
->limit(50),
])
])
->actions([
ViewAction::make()
->modalHeading(fn (Message $record) => ($record->title))
->infolist(Message::getInfolist())
->slideOver(),
]);
}
9 replies