feat: add containerized deployment workflow
This commit is contained in:
@@ -30,9 +30,10 @@ class UpdateUserAvatar
|
||||
$color = $this->colorFor($user);
|
||||
$path = sprintf('avatars/generated/%d-%s.svg', $user->id, (string) Str::uuid());
|
||||
|
||||
$stored = Storage::disk('public')->put(
|
||||
$stored = Storage::disk($this->avatarDisk())->put(
|
||||
$path,
|
||||
$this->svg($this->initials($user->name), $color),
|
||||
['ContentType' => 'image/svg+xml'],
|
||||
);
|
||||
|
||||
if (! $stored) {
|
||||
@@ -53,7 +54,7 @@ class UpdateUserAvatar
|
||||
public function upload(User $user, UploadedFile $avatar): User
|
||||
{
|
||||
$oldPath = $user->avatar_path;
|
||||
$path = $avatar->store('avatars/uploads', 'public');
|
||||
$path = $avatar->store('avatars/uploads', $this->avatarDisk());
|
||||
|
||||
if (! is_string($path)) {
|
||||
throw new RuntimeException('Uploaded avatar could not be stored.');
|
||||
@@ -90,7 +91,14 @@ class UpdateUserAvatar
|
||||
return;
|
||||
}
|
||||
|
||||
Storage::disk('public')->delete($path);
|
||||
Storage::disk($this->avatarDisk())->delete($path);
|
||||
}
|
||||
|
||||
private function avatarDisk(): string
|
||||
{
|
||||
$disk = config('filesystems.avatar_disk', 'public');
|
||||
|
||||
return is_string($disk) && $disk !== '' ? $disk : 'public';
|
||||
}
|
||||
|
||||
private function initials(string $name): string
|
||||
|
||||
Reference in New Issue
Block a user