-
app/Models/User.php
Open in GitHubuse Illuminate\Foundation\Auth\User as Authenticatable; use Spatie\MediaLibrary\HasMedia; class User extends Authenticatable implements MustVerifyEmail, HasMedia { // ... public function getPhotoUrlAttribute() { return $this->hasMedia('photos') ? $this->getFirstMediaUrl('photos') : "https://api.dicebear.com/7.x/initials/svg?backgroundType=gradientLinear&fontFamily=Helvetica&fontSize=40&seed=".urlencode($this->name); } }
-
resources/js/Components/UserAvatar.vue
Open in GitHub<script setup> const { size } = defineProps({ user: { type: Object, required: true, }, size: { type: String, default: "md", }, }); // ... </script> <template> <img :src="user.photo_url" :class="userSize" :alt="user.name" class="rounded-full" /> </template>