Skip to content

Commit

Permalink
fix(widgets): update LatestUsers query to use the configured resource (
Browse files Browse the repository at this point in the history
…#34)

* feat(widgets): update LatestUsers query to use the configured resource instead of model

* fix: allow builder to read query from user resource

---------

Co-authored-by: Craig Smith <952595+phpsa@users.noreply.github.com>
  • Loading branch information
RickAtCD and phpsa committed May 15, 2023
1 parent a5bd787 commit a09a2a8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
3 changes: 2 additions & 1 deletion config/filament-authentication.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
'LatestUsers' => [
'enabled' => true,
'limit' => 5,
'sort' => 0
'sort' => 0,
'paginate' => false
],
],
'preload_roles' => true,
Expand Down
10 changes: 4 additions & 6 deletions src/Widgets/LatestUsersWidget.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,9 @@ class LatestUsersWidget extends TableWidget
{
protected function getTableQuery(): Builder
{
$userClass = config('filament-authentication.models.User');

return $userClass::query()
->latest()
->limit(Config::get('filament-authentication.Widgets.LatestUsers.limit'));
return $this->getResource()::getEloquentQuery()
->latest()
->limit(Config::get('filament-authentication.Widgets.LatestUsers.limit'));
}

protected function getTableColumns(): array
Expand All @@ -33,7 +31,7 @@ protected function getTableColumns(): array

protected function isTablePaginationEnabled(): bool
{
return false;
return Config::get('filament-authentication.Widgets.LatestUsers.paginate', false)
}

public static function canView(): bool
Expand Down

0 comments on commit a09a2a8

Please sign in to comment.