Closed quasiperfect closed 11 months ago
Hi @quasiperfect
Sure! :)
To be able to extend and modify the resource, you should override in your project the AuthenticationLogResource
and the AuthenticationLogResource
's ListAuthenticationLogs.php
page.
AuthenticationLogResource.php
, override the getPages()
method pointing to your page,ListAuthenticationLogs.php
page, set the $resource
property to your resource.E.g.:
Your AuthenticationLogResource.php
resource extending Tapp\FilamentAuthenticationLog\Resources\AuthenticationLogResource
:
<?php
namespace App\Filament\Resources;
//...
use Rappasoft\LaravelAuthenticationLog\Models\AuthenticationLog;
use Tapp\FilamentAuthenticationLog\Resources\AuthenticationLogResource as BaseAuthenticationLogResource;
use App\Filament\Resources\AuthenticationLogResource\Pages;
class AuthenticationLogResource extends BaseAuthenticationLogResource
{
public static function table(Table $table): Table
{
return $table
->query(AuthenticationLog::where('ip_address', '127.0.0.1')) // some custom query
->columns([
// ...
])
->actions([
// ...
])
->filters([
// ...
]);
}
public static function getPages(): array
{
return [
'index' => Pages\ListAuthenticationLogs::route('/'), // your page here (see namespace above: use App\Filament\Resources\AuthenticationLogResource\Pages;)
];
}
}
Your ListAuthenticationLogs.php
page:
<?php
namespace App\Filament\Resources\AuthenticationLogResource\Pages;
use Filament\Resources\Pages\ListRecords;
use App\Filament\Resources\AuthenticationLogResource;
class ListAuthenticationLogs extends ListRecords
{
protected static string $resource = AuthenticationLogResource::class; // you resource here (see namespace above: use App\Filament\Resources\AuthenticationLogResource;)
}
Please let me know if it's working for you :)
thanks @andreia it works great :)
hi
i have overridden you resource class and i want to use
getEloquentQuery
to filter the results but i didn't had any luck. can you be so kind as to post a example on how to do that ?