Use Livewire pagination inside a ViewField

I have some additional data displayed inside a form that I want to paginate over. Is it possible to use Livewire's ajax pagination with a Filament component?
class ExampleField extends Forms\Components\ViewField
{
use WithPagination;

public static function make(string $name): static
{
$static = parent::make($name);

$static->viewData([
'example' => Models\Example::paginate(5)
]);

return $static;
}
}
class ExampleField extends Forms\Components\ViewField
{
use WithPagination;

public static function make(string $name): static
{
$static = parent::make($name);

$static->viewData([
'example' => Models\Example::paginate(5)
]);

return $static;
}
}
3 Replies
toeknee
toeknee2y ago
I’m you could just load a livewire component within filament by using the view field rendering the livewire components blade
gizmojo
gizmojoOP2y ago
🤦‍♂️ oh yeah will give that a go cheers Amazing that worked perfectly. Slightly off-topic but do you need to check the Filament::auth()->check in a custom livewire component?
toeknee
toeknee2y ago
If you have a custom livewire component you could do an authorization check within the mount method if and only if you allow it to be accessed from a route. Otherwise you'd need to find a way to process it on the server side swhich to my knowledge isn't possible. Ideally just use Laravel Policies and that should keep your models covered
Want results from more Discord servers?
Add your server