Skip to content

Commit

Permalink
enhancements on upload doc
Browse files Browse the repository at this point in the history
  • Loading branch information
devajmeireles committed Jan 26, 2024
1 parent 90e916b commit 9780903
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 10 deletions.
38 changes: 33 additions & 5 deletions app/Enums/Examples/Form/Upload.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,18 @@ class Upload
public function deleteUpload(array $content): void
{
/*
the $content contains:
[
'temporary_name',
'real_name',
'extension',
'size',
'path',
'url',
]
*/
if (! $this->photo) {
return;
}
Expand Down Expand Up @@ -163,28 +175,32 @@ public function mount(): void
'path' => $file->getPath(),
'url' => Storage::url('images/'.$file->getFilename()),
])->toArray();
// In this example we are using the images that exists
// in the application server, but you can use any other
// files for example, files that are stored in the S3 bucket.
}
// ...
}
HTML;

public const BLADE_COMPONENT_FOR_STATIC_USAGE = <<<'HTML'
<!-- All other options is available:
<!-- All other options is available when static:
label, hint, tip,
footer slot,
events (only remove)
rename delete method -->
events (only remove event)
renaming delete method -->
<!-- WITHOUT delete action -->
<x-upload wire:model="photos" static />
<!-- WITH delete action -->
<x-upload wire:model="photos" static delete />
<!-- In static mode you can set a custom placeholder for the input -->
<!-- You can set a custom placeholder for the input -->
<x-upload wire:model="photos"
:placeholder="count($photos) . ' images'" {{-- [tl! add] --}}
:placeholder="count($photos) . ' images'" {{-- [tl! highlight] --}}
static
delete />
HTML;
Expand All @@ -195,6 +211,18 @@ public function mount(): void
public function deleteUpload(array $content): void
{
/*
the $content contains:
[
'temporary_name',
'real_name', // same of 'temporary_name' in static mode
'extension',
'size',
'path',
'url',
]
*/
if (empty($this->photos)) {
return;
}
Expand Down
5 changes: 0 additions & 5 deletions resources/views/documentation/form/upload.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,6 @@
<x-preview>
<livewire:documentation.form.upload.static />
</x-preview>
<p class="mt-4">
Keep in mind that in all this example we use existing images in the application,
however you can bring your existing images, for example, on S3. The code is
yours, you can do whatever you want.
</p>
</x-section>
<x-slot:navigation>
<x-slot:back>
Expand Down

0 comments on commit 9780903

Please sign in to comment.