F
Filamentā€¢12mo ago
Wirkhof

How to show name instead of avatar/black circle with initials?

I don't want avatar. I want the user name something like Auth::user->name I guess in the top right corner. How to do that? Right now I have there a black circle with initials.
Solution:
Or just use https://github.com/laravolt/avatar if you want it local.
GitHub
GitHub - laravolt/avatar: Plug n play avatar, turn name, email, and...
Plug n play avatar, turn name, email, and any other string into beautiful avatar (or gravatar), effortless. - GitHub - laravolt/avatar: Plug n play avatar, turn name, email, and any other string i...
Jump to solution
28 Replies
Wirkhof
WirkhofOPā€¢12mo ago
Is there any method to do that? Like ->avatar('name') ? or ->avatar('email') ?
toeknee
toekneeā€¢12mo ago
I don't thinkso, you would need to disable the avatar and just add a render hook to render the users name.
Wirkhof
WirkhofOPā€¢12mo ago
I don't understand. I don't want avatar. How to remove it and show my name or email instead? In which file can I edit the visual representation of the top banner with the avatar and sway it for <div>{{ Auth::user->name }}</div> instead? I don't even need a name of the user - it will be always me. I want there perhaps just a log out button. No popup,drop down menu. just a user name and a logout link Why is such a simple thing so complicated? šŸ˜­ I don't want avatars, I want {{ Auth::user->name }}
Wirkhof
WirkhofOPā€¢12mo ago
This seems super complicated for me. I will probably just create my custom provider and generate an svg image with initials myself. https://stackoverflow.com/questions/28128491/center-text-in-circle-with-svg I don't understand why wouldn't it be done locally in the first place. Would it even work on intranet in an off-line mode - think some engineering factory with a filament backend for workers, etc.
Stack Overflow
Center text in circle with SVG
I'm trying to center text in a circle with SVG. The size of the text will be dynamic. My code on Plunker: <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/
toeknee
toekneeā€¢12mo ago
It can be done locally, if you want to keep the avatar you just simply add the getAvatar function to the user model and fetch it from whereever you want. But you specifically requested it to not render at all. All of this is in the docs.
Wirkhof
WirkhofOPā€¢12mo ago
Yeah, but you use super advanced jargon and abstract terms. It's hard to understand you as a beginner.
toeknee
toekneeā€¢12mo ago
It's fairly basic, not advanced jargon. You should understand the basics of PHP before using Laravel and Filamentphp.
Wirkhof
WirkhofOPā€¢12mo ago
I have been sucessfuly using Livewire, but Filament seems to be super abstract and hard to grasp and visualize. It's all classes and implementations/interfaces
toeknee
toekneeā€¢12mo ago
It's an abstracted approach yes, because it allows rapid functional development with crazy consistency throughtout. If you have a decent IDE you will see all the layers, but the documentation explains everything fairly well.
Wirkhof
WirkhofOPā€¢12mo ago
evertyhing is overwritten and changed somewhere in the chain.
toeknee
toekneeā€¢12mo ago
It's only overwritten when you want to change something
Wirkhof
WirkhofOPā€¢12mo ago
Yes, it's super opinionated. for 95% it's great. But sometimes, like in this case you spend a few hours solving such a thing that would be done in 2 minutes in plain livewire/blade component
toeknee
toekneeā€¢12mo ago
But it's only not because you don't understand it.... I can do this is 2 minutes. You can't because you are not familiar with it.
Wirkhof
WirkhofOPā€¢12mo ago
Well, I doubt you wouldn't have to google svg tags
toeknee
toekneeā€¢12mo ago
Once you learn render hooks, you'll understand how powerfull it can be, again another learning curve
Wirkhof
WirkhofOPā€¢12mo ago
and how to center text and stuff
toeknee
toekneeā€¢12mo ago
center text is easy? depending on where, ->alignCenter() again all explained in the docs or ->extraAttributes(['class' => 'text-center'])
Wirkhof
WirkhofOPā€¢12mo ago
By the way, this is off topic but this is a nice link https://svg-tutorial.com/svg/basic-shapes
SVG Tutorial
Day 1: How to Draw Basic Shapes with SVG - SVG Tutorial
Learn how to draw basic shaped with SVG. In the first example we draw a Christmas Ornament with two circles and a rectangle element.
Wirkhof
WirkhofOPā€¢12mo ago
O saw it on hackernews a few days ago SVG is super underrated
toeknee
toekneeā€¢12mo ago
That is for basic shapes, but filament uses bladeicons so you can render any SVG from blade icons.
Wirkhof
WirkhofOPā€¢12mo ago
Yeah I will need to create a circle and put the initials there nothing fancy. I think I will be able to do it in a few minutes or so
Solution
toeknee
toekneeā€¢12mo ago
Or just use https://github.com/laravolt/avatar if you want it local.
GitHub
GitHub - laravolt/avatar: Plug n play avatar, turn name, email, and...
Plug n play avatar, turn name, email, and any other string into beautiful avatar (or gravatar), effortless. - GitHub - laravolt/avatar: Plug n play avatar, turn name, email, and any other string i...
Wirkhof
WirkhofOPā€¢12mo ago
OK, thanks I will look at it.
Wirkhof
WirkhofOPā€¢12mo ago
Try that example you linked. It's not working šŸ˜‰ I am trying the laravolt/avatar now though. It can do svg. So perhaps it will be the solution for now. Hopefully it will work with Filament 3 Hmm, I don't know how to make it with FIlament šŸ˜‰ Will ask in another question.
Dennis Koch
Dennis Kochā€¢12mo ago
you spend a few hours solving such a thing that would be done in 2 minutes in plain livewire/blade
That's the down side of every abstraction layer.
Wirkhof
WirkhofOPā€¢12mo ago
@toeknee Laravolt/avatar seems to be working nicely - it seems to not trigger any external URLs. Just be careful to import the right file so don't import this in your custom provider file:
use Laravolt\Avatar\Avatar;
use Laravolt\Avatar\Avatar;
But import this instead:
use Laravolt\Avatar\Facade as Avatar;
use Laravolt\Avatar\Facade as Avatar;
Want results from more Discord servers?
Add your server