fix: default filesystem name
This commit is contained in:
@@ -21,12 +21,12 @@ trait HasProfilePhoto
|
|||||||
tap($this->profile_photo_path, function ($previous) use ($photo, $storagePath) {
|
tap($this->profile_photo_path, function ($previous) use ($photo, $storagePath) {
|
||||||
$this->forceFill([
|
$this->forceFill([
|
||||||
'profile_photo_path' => $photo->storePublicly(
|
'profile_photo_path' => $photo->storePublicly(
|
||||||
$storagePath, ['disk' => 'public']
|
$storagePath, ['disk' => $this->profilePhotoDisk()]
|
||||||
),
|
),
|
||||||
])->save();
|
])->save();
|
||||||
|
|
||||||
if ($previous) {
|
if ($previous) {
|
||||||
Storage::disk('public')->delete($previous);
|
Storage::disk($this->profilePhotoDisk())->delete($previous);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -42,7 +42,7 @@ trait HasProfilePhoto
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Storage::disk('public')->delete($this->profile_photo_path);
|
Storage::disk($this->profilePhotoDisk())->delete($this->profile_photo_path);
|
||||||
|
|
||||||
$this->forceFill([
|
$this->forceFill([
|
||||||
'profile_photo_path' => null,
|
'profile_photo_path' => null,
|
||||||
@@ -56,7 +56,7 @@ trait HasProfilePhoto
|
|||||||
{
|
{
|
||||||
return Attribute::get(function (): string {
|
return Attribute::get(function (): string {
|
||||||
return $this->profile_photo_path
|
return $this->profile_photo_path
|
||||||
? Storage::disk('public')->url($this->profile_photo_path)
|
? Storage::disk($this->profilePhotoDisk())->url($this->profile_photo_path)
|
||||||
: $this->defaultProfilePhotoUrl();
|
: $this->defaultProfilePhotoUrl();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -74,4 +74,14 @@ trait HasProfilePhoto
|
|||||||
|
|
||||||
return 'https://ui-avatars.com/api/?name='.urlencode($name).'&color=7F9CF5&background=EBF4FF';
|
return 'https://ui-avatars.com/api/?name='.urlencode($name).'&color=7F9CF5&background=EBF4FF';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the disk that profile photos should be stored on.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
protected function profilePhotoDisk()
|
||||||
|
{
|
||||||
|
return config('filesystems.default', 'local');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user