Skip to content
This repository has been archived by the owner on Oct 1, 2021. It is now read-only.

Commit

Permalink
fix: profile avatar upload (#140)
Browse files Browse the repository at this point in the history
  • Loading branch information
leMaur authored May 6, 2021
1 parent 5a1740d commit ea7fb98
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
9 changes: 7 additions & 2 deletions src/Components/UpdateProfilePhotoForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,14 @@ public function updatedImageSingle(): void
{
$this->validateImageSingle();

$file = $this->imageSingle->storePubliclyAs('uploads', $this->imageSingle->hashName());
$file = $this->imageSingle;

$this->user
->addMedia($file->getRealPath())
->withResponsiveImages()
->usingFileName($file->hashName())
->toMediaCollection('photo');

$this->user->addMediaFromDisk($file)->withResponsiveImages()->toMediaCollection('photo');
$this->user->refresh();
}

Expand Down
4 changes: 2 additions & 2 deletions tests/Components/UpdateProfilePhotoFormTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
it('can upload a photo', function () {
$this
->mock(FileAdderFactory::class)
->shouldReceive('createFromDisk->withResponsiveImages->toMediaCollection')
->shouldReceive('create->withResponsiveImages->usingFileName->toMediaCollection')
->once();

$photo = UploadedFile::fake()->image('logo.jpeg', 150, 150);
Expand Down Expand Up @@ -45,7 +45,7 @@
it('can delete a photo', function () {
$this
->mock(FileAdderFactory::class)
->shouldReceive('createFromDisk->withResponsiveImages->toMediaCollection')
->shouldReceive('create->withResponsiveImages->usingFileName->toMediaCollection')
->once();

$media = Mockery::mock(Media::class);
Expand Down

0 comments on commit ea7fb98

Please sign in to comment.