Lea
Lea
FFilament
Created by Lea on 3/19/2024 in #❓┊help
ReCaptcha with Livewire Wizard
No description
5 replies
FFilament
Created by Lea on 1/26/2024 in #❓┊help
Can't dispatch inside a Filament component in my blade
Hello, i'm trying to use $dispatch to download file, I'm using Spatie Media Library, with S3 as my disk. My function download() simply doesn't run after I click the download button using @click="$dispatch('download-document')"
2 replies
FFilament
Created by Lea on 1/13/2024 in #❓┊help
View resource page with getFormSchema doesn't work with Filament 3 after update
No description
4 replies
FFilament
Created by Lea on 1/12/2024 in #❓┊help
I'm trying to add a download button in a extended Custom Field
Hello, I'm trying to add a download button for a media that use Spatie Media Library, I have the function, but i can't use it in my blade when i use wire:click="download", it goes to the main page file, and i get an error because obviously, the function doesn't exists there, but in the Custom Field file
<?php

namespace App\Forms\Components;

use Closure;
use Filament\Forms\Components\Field;
use Spatie\MediaLibrary\MediaCollections\Models\Collections\MediaCollection;
use Spatie\MediaLibrary\MediaCollections\Models\Media;
use Str;
use Carbon\Carbon;


class DocumentViewer extends Field
{
protected string $view = 'forms.components.document-viewer';


protected Closure|Media $document;

public function document(Closure|Media $document): static
{
$this->document = $document;

return $this;
}

public function getUrl(): ?string
{
$media = $this->evaluate($this->document);
if ($media instanceof MediaCollection) {
/** @var Media $document */
$document = $media->first();

return $document->getTemporaryUrl(Carbon::now()->addMinutes(5));
}

return null;
}

public function download()
{
$media = $this->evaluate($this->document);
if ($media instanceof MediaCollection) {
/** @var Media $document */
return response()->download($media->first()->getPath(), $media->first()->file_name);
}

return null;
}

public function getType(): ?string
{
$media = $this->evaluate($this->document);
if ($media instanceof MediaCollection) {
/** @var Media $document */
$document = $media->first();

return $document->getTypeFromMime();
}

return null;
}

public function getDocumentId(): string
{
return 'document-' . Str::random(12);
}
}
<?php

namespace App\Forms\Components;

use Closure;
use Filament\Forms\Components\Field;
use Spatie\MediaLibrary\MediaCollections\Models\Collections\MediaCollection;
use Spatie\MediaLibrary\MediaCollections\Models\Media;
use Str;
use Carbon\Carbon;


class DocumentViewer extends Field
{
protected string $view = 'forms.components.document-viewer';


protected Closure|Media $document;

public function document(Closure|Media $document): static
{
$this->document = $document;

return $this;
}

public function getUrl(): ?string
{
$media = $this->evaluate($this->document);
if ($media instanceof MediaCollection) {
/** @var Media $document */
$document = $media->first();

return $document->getTemporaryUrl(Carbon::now()->addMinutes(5));
}

return null;
}

public function download()
{
$media = $this->evaluate($this->document);
if ($media instanceof MediaCollection) {
/** @var Media $document */
return response()->download($media->first()->getPath(), $media->first()->file_name);
}

return null;
}

public function getType(): ?string
{
$media = $this->evaluate($this->document);
if ($media instanceof MediaCollection) {
/** @var Media $document */
$document = $media->first();

return $document->getTypeFromMime();
}

return null;
}

public function getDocumentId(): string
{
return 'document-' . Str::random(12);
}
}
3 replies
FFilament
Created by Lea on 10/7/2023 in #❓┊help
I'm searching for a rich text editor that can do this
No description
5 replies
FFilament
Created by Lea on 5/10/2023 in #❓┊help
acceptedFileTypes(['text/csv']) doesn't validate CSV with semicolons
I'm trying to use FileUpload, but the csv file only works if the delimeter is , (commas) When I upload one with ; (semicolons) it doesn't validate I kind of fix it adding text/plain, but I need to validate at least that the extensions ends with .csv, xls or xlsx Anyone knows how? ->acceptedFileTypes( [ 'csv', 'text/csv', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'application/vnd.ms-excel', 'application/vnd.oasis.opendocument.spreadsheet', 'text/plain' ] )
4 replies