Skip to content

Commit

Permalink
Merge pull request #18 from TappNetwork/update_relation_manager
Browse files Browse the repository at this point in the history
Show custom field on relation manager
  • Loading branch information
andreia authored Jun 25, 2024
2 parents af00d4d + 8f6ce13 commit 43d63a1
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/RelationManagers/AuthenticationLogsRelationManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Tapp\FilamentAuthenticationLog\RelationManagers;

use Filament\Facades\Filament;
use Filament\Resources\RelationManagers\RelationManager;
use Filament\Tables;
use Filament\Tables\Columns\TextColumn;
Expand All @@ -11,6 +10,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 +35,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 43d63a1

Please sign in to comment.