Skip to content

Commit

Permalink
Add ability to show custom field on relation manager
Browse files Browse the repository at this point in the history
  • Loading branch information
andreia committed Jun 25, 2024
1 parent af00d4d commit 2a66fa4
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/RelationManagers/AuthenticationLogsRelationManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\HtmlString;
use Illuminate\Support\Str;
use Tapp\FilamentAuthenticationLog\FilamentAuthenticationLogPlugin;

class AuthenticationLogsRelationManager extends RelationManager
{
Expand All @@ -35,7 +36,11 @@ public function table(Table $table): Table
return new HtmlString('—');
}

return new HtmlString('<a href="'.route('filament.'.Filament::getCurrentPanel()->getId().'.resources.'.Str::plural((Str::lower(class_basename($record->authenticatable::class)))).'.edit', ['record' => $record->authenticatable_id]).'" class="inline-flex items-center justify-center hover:underline focus:outline-none focus:underline filament-tables-link text-primary-600 hover:text-primary-500 text-sm font-medium filament-tables-link-action">'.$record->authenticatable->name.'</a>');
$authenticatableFieldToDisplay = config('filament-authentication-log.authenticatable.field-to-display');

$authenticatableDisplay = $authenticatableFieldToDisplay !== null ? $record->authenticatable->{$authenticatableFieldToDisplay} : class_basename($record->authenticatable::class);

return new HtmlString('<a href="' . route('filament.' . FilamentAuthenticationLogPlugin::get()->getPanelName() . '.resources.' . Str::plural((Str::lower(class_basename($record->authenticatable::class)))) . '.edit', ['record' => $record->authenticatable_id]) . '" class="inline-flex items-center justify-center hover:underline focus:outline-none focus:underline filament-tables-link text-primary-600 hover:text-primary-500 text-sm font-medium filament-tables-link-action">'.$authenticatableDisplay.'</a>');
})
->sortable(),
Tables\Columns\TextColumn::make('ip_address')
Expand Down

0 comments on commit 2a66fa4

Please sign in to comment.