System component Profile

# Make

The system component Profile is used to display information about an authorized user in MoonShine.

You can create a Profile using the static method make() class Profile.

make(bool $withBorder = false)

$withBorder - to split before the component.

namespace App\MoonShine;
 
use MoonShine\Components\Layout\LayoutBlock;
use MoonShine\Components\Layout\LayoutBuilder;
use MoonShine\Components\Layout\Menu;
use MoonShine\Components\Layout\Profile;
use MoonShine\Components\Layout\Sidebar;
use MoonShine\Contracts\MoonShineLayoutContract;
 
final class MoonShineLayout implements MoonShineLayoutContract
{
public static function build(): LayoutBuilder
{
return LayoutBuilder::make([
Sidebar::make([
Menu::make()->customAttributes(['class' => 'mt-2']),
Profile::make(withBorder: true)
]),
 
//...
]);
}
}

# Default avatar

The defaultAvatar() method allows you to override the default profile avatar.

defaultAvatar(string $url)
  • $url - default avatar url.
use MoonShine\Components\Layout\Profile;
 
//...
 
Profile::make()
->defaultAvatar("https://ui-avatars.com/api/?name=$name")