code refactoring with @cuneytsenturk after dropzone improvement

This commit is contained in:
Sevan Nerse
2021-01-30 22:07:01 +03:00
parent 8c84d0cf80
commit 05d19c435d
3 changed files with 21 additions and 6 deletions

View File

@@ -37,20 +37,35 @@
@endif
@if (!empty($value))
@php
$attachments = [];
@endphp
@if (is_array($value))
@foreach($value as $attachment)
@php
$attachments[] = ['name' => $attachment->filename . '.' . $attachment->extension, 'path' => route('uploads.get', $attachment->id), 'downloadPath' => route('uploads.download', $attachment->id)];
$attachments[] = [
'name' => $attachment->filename . '.' . $attachment->extension,
'path' => route('uploads.get', $attachment->id),
'downloadPath' => route('uploads.download', $attachment->id)
];
@endphp
@endforeach
@elseif ($value instanceof \Plank\Mediable\Media)
@php
$attachments = ['name' => $value->filename . '.' . $value->extension, 'path' => route('uploads.get', $value->id)];
$attachments = array($attachments);
$attachments[] = [
'name' => $value->filename . '.' . $value->extension,
'path' => route('uploads.get', $value->id)
];
@endphp
@else
@php
$attachments = array();
$attachment = \Plank\Mediable\Media::find($value);
$attachments[] = [
'name' => $attachment->filename . '.' . $attachment->extension,
'path' => route('uploads.get', $attachment->id)
];
@endphp
@endif