use Illuminate\Foundation\Auth\User as Authenticatable;
use DanJamesMills\InitialsAvatarGenerator\Traits\HasAvatar;
class User extends Authenticatable
{
use HasAvatar;
// ...
}
use Illuminate\Foundation\Auth\User as Authenticatable;
use DanJamesMills\InitialsAvatarGenerator\Traits\HasAvatar;
use Illuminate\Database\Eloquent\Casts\Attribute;
class User extends Authenticatable
{
/**
* Get the user's avatar.
*
* @return \Illuminate\Database\Eloquent\Casts\Attribute
*/
protected function avatar(): Attribute
{
return Attribute::make(
get: fn ($value) => url("/storage/avatars/{$value}"),
);
}
}
use Illuminate\Foundation\Auth\User as Authenticatable;
use DanJamesMills\InitialsAvatarGenerator\Traits\HasAvatar;
class User extends Authenticatable
{
/**
* Used to define the fields of which initials avatar
* generator will create initials from.
*
* @return string
*/
protected function defineNameInitialsAvatarGenerator(): string
{
return $this->name;
}
}
use Illuminate\Foundation\Auth\User as Authenticatable;
use DanJamesMills\InitialsAvatarGenerator\Traits\HasAvatar;
class User extends Authenticatable
{
/**
* Used to define the column field name of which
* you want to save avatar image to.
*
* @return string
*/
protected function defineAvatarColumnName(): string
{
return 'avatarColumnName';
}
}