Update packages and various code for laravel 9

This commit is contained in:
James Cole
2022-03-19 08:10:42 +01:00
parent 45d99aa456
commit 5ca0a9f75a
7 changed files with 750 additions and 261 deletions

View File

@@ -31,7 +31,6 @@ use FireflyIII\Models\Attachment;
use FireflyIII\Models\Note;
use FireflyIII\User;
use Illuminate\Contracts\Encryption\DecryptException;
use Illuminate\Contracts\Filesystem\FileNotFoundException;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Storage;
use Log;
@@ -101,12 +100,7 @@ class AttachmentRepository implements AttachmentRepositoryInterface
$unencryptedContent = '';
if ($disk->exists($file)) {
$encryptedContent = '';
try {
$encryptedContent = $disk->get($file);
} catch (FileNotFoundException $e) {
Log::error($e->getMessage());
}
$encryptedContent = (string) $disk->get($file);
try {
$unencryptedContent = Crypt::decrypt($encryptedContent); // verified
@@ -129,7 +123,7 @@ class AttachmentRepository implements AttachmentRepositoryInterface
{
$note = $attachment->notes()->first();
if (null !== $note) {
return (string)$note->text;
return (string) $note->text;
}
return null;
@@ -175,20 +169,20 @@ class AttachmentRepository implements AttachmentRepositoryInterface
$attachment->title = $data['title'];
}
if (array_key_exists('filename', $data) && '' !== (string)$data['filename'] && $data['filename'] !== $attachment->filename) {
if (array_key_exists('filename', $data) && '' !== (string) $data['filename'] && $data['filename'] !== $attachment->filename) {
$attachment->filename = $data['filename'];
}
// update model (move attachment)
// should be validated already:
if (array_key_exists('attachable_type', $data) && array_key_exists('attachable_id', $data)) {
$attachment->attachable_id = (int)$data['attachable_id'];
$attachment->attachable_id = (int) $data['attachable_id'];
$attachment->attachable_type = sprintf('FireflyIII\\Models\\%s', $data['attachable_type']);
}
$attachment->save();
$attachment->refresh();
if (array_key_exists('notes', $data)) {
$this->updateNote($attachment, (string)$data['notes']);
$this->updateNote($attachment, (string) $data['notes']);
}
return $attachment;