|
Hi, I'm using I cannot get the EventServiceProvider.php : Using Filament to drag/sort. The sorting works perfectly, but the event never fires. |
Replies: 1 comment
|
Well, I figured out that Filament does not call public function reorderTable(array $order, int | string | null $draggedRecordKey = null): void
{
// parent::reorderTable($order, $draggedRecordKey);
$relation = $this->ownerRecord->{self::$relationship};
if ($relation instanceof \Illuminate\Database\Eloquent\Collection && $relation->isNotEmpty()) {
$class = get_class($relation->first());
}else{
$class = get_class($relation);
}
$class::setNewOrder($order);
}After all of this I realized that the event does not pass any records which triggered the event (which is what I needed), only the class name/path, so even this falls a bit short for my needs, but hopefully the above code helps somebody. |
Well, I figured out that Filament does not call
::setNewSort()and that's why I cannot listen for the event.In a Filament resource or in my case a Filament relationManager we can override Filament's sorting mechanism. Here's what I came up with: