Files
2026-05-09 17:32:17 +02:00

51 lines
1.2 KiB
PHP
Executable File

<?php
declare(strict_types=1);
namespace App\Filament\Tables\Columns;
use Filament\Tables\Columns\Column;
class UserAvatarColumn extends Column
{
protected ?string $avatarOptions = null;
protected ?string $figurePointer = null;
#[\Override]
protected string $view = 'filament.tables.columns.user-avatar';
public function getAvatarUrl(): string
{
$record = $this->getRecord();
$figureImagerUrl = setting('avatar_imager');
if (! $figureImagerUrl) {
return '';
}
$figure = $this->figurePointer
? data_get($record, $this->figurePointer)
: $record->look;
return "{$figureImagerUrl}{$figure}{$this->avatarOptions}";
}
public function options(string $avatarOptions): UserAvatarColumn
{
$this->avatarOptions = $avatarOptions;
return $this;
}
/**
* Used to reference the user's figure string through relationships in a Laravel model. By default it will take the look property of the main class.
*/
public function pointer(string $figurePointer): UserAvatarColumn
{
$this->figurePointer = $figurePointer;
return $this;
}
}