Skip to main content

Black Friday 2025! Only until December 1st: coupon FRIDAY25 for 40% off Yearly/Lifetime membership!

Read more here

nabilhassen/larasense

62 stars
2 code files
View nabilhassen/larasense on GitHub

app/Livewire/Profile/UploadProfilePicture.php

Open in GitHub
use Livewire\Attributes\On;
use Livewire\Attributes\Rule;
use Livewire\Component;
use Spatie\LivewireFilepond\WithFilePond;
 
class UploadProfilePicture extends Component
{
// ...
 
#[On('FilePond:removefile')]
public function validateUploadedFile()
{
$this->validate();
 
auth()->user()->update([
'avatar_url' => $this->file?->store('avatars', 'public'),
]);
 
if (auth()->user()->wasChanged('avatar_url')) {
$this->dispatch('update-user-profile-picture');
}
 
return true;
}
 
// ...
}

resources/views/livewire/user-avatar.blade.php

Open in GitHub
<div x-data>
<img
loading="lazy"
src="{{ auth()->user()->avatar }}"
x-on:update-user-profile-picture.window="$wire.$refresh()"
/>
</div>

We'd Love Your Feedback

Tell us what you like or what we can improve

Feel free to share anything you like or dislike about this page or the platform in general.