ChesterS
ChesterS
FFilament
Created by Matthew on 11/19/2024 in #❓┊help
Use HeaderAction to upload file in FileUpload.
Not sure what you're trying to do, but you can use the saveUploadedFileUsing method.
Actions\Action::make('test')
->form([
FileUpload::make('files')
->saveUploadedFileUsing(fn ($file) => dd($file))
])
Actions\Action::make('test')
->form([
FileUpload::make('files')
->saveUploadedFileUsing(fn ($file) => dd($file))
])
If you want to handle the file creation manually, you can set storeFiles(false) in the fileupload, and then get the raw state and do w/e you want
Actions\Action::make('test')
->form([
FileUpload::make('files')
->storeFiles(false)
])
->action(function(Form $form) {
dd($form->getRawState());
}),
Actions\Action::make('test')
->form([
FileUpload::make('files')
->storeFiles(false)
])
->action(function(Form $form) {
dd($form->getRawState());
}),
hope it helps
4 replies
FFilament
Created by Tudor on 11/11/2024 in #❓┊help
canAccess function generate a lot of duplicate queries
It didn't duplicate for every user, it did for every event. In any case, it doesn't matter since you found a workaround 👍
5 replies
FFilament
Created by Tudor on 11/11/2024 in #❓┊help
canAccess function generate a lot of duplicate queries
Is this in a table or a list of sorts? You might need to refactor how you check what people can see in that page - instead of checking if they have access to each event one-by-one, maybe only show the events they do have access to and skip the canAccess() check entirely? Or maybe eager-load the event contestants and use a different policy?
Depends o what you're trying to achieve. Also, your query can be improved.
public static function canAccess(): bool
{
return Filament::getTenant()->eventContestants()->where('user_id', auth()->id())->exists();
}
public static function canAccess(): bool
{
return Filament::getTenant()->eventContestants()->where('user_id', auth()->id())->exists();
}
Some other improvements can probably be made, but I've never used tenancies.
5 replies
FFilament
Created by Moktar on 11/5/2024 in #❓┊help
manually refresh table content
The suggestions so far should cover you. Look into livewire's event documentation for more details
10 replies
FFilament
Created by Moktar on 11/5/2024 in #❓┊help
manually refresh table content
You don't need a custom page. Filament pages are livewire components, you can add listeners to those classes like you would to any other livewire component
10 replies
FFilament
Created by Vladyslav on 11/8/2024 in #❓┊help
Multiple definitions
Either way, this is not related to filament 😦
4 replies
FFilament
Created by Vladyslav on 11/8/2024 in #❓┊help
Multiple definitions
No description
4 replies
FFilament
Created by Jamie Cee on 11/7/2024 in #❓┊help
Unable to interact with last record of table, or the pagination when using large amounts of data.
What have you tried so far?
6 replies
FFilament
Created by Codrin on 11/6/2024 in #❓┊help
How to move CreateAction inside HeaderActions
There's no build-in method AFAIK. You can try with css or something, or maybe render hooks. https://filamentphp.com/docs/3.x/support/render-hooks
5 replies
FFilament
Created by Emmanuel71 on 11/4/2024 in #❓┊help
How to use a custom path with spatie media library plugin?
Cool, it's similar to what I did. Just a tip, you don't have to re-implement every method, you can just extend the base name generator and just override the getPath() method
13 replies
FFilament
Created by Emmanuel71 on 11/4/2024 in #❓┊help
How to use a custom path with spatie media library plugin?
You need that to override the path generator or use a custom model
13 replies
FFilament
Created by Emmanuel71 on 11/4/2024 in #❓┊help
How to use a custom path with spatie media library plugin?
13 replies
FFilament
Created by Emmanuel71 on 11/4/2024 in #❓┊help
How to use a custom path with spatie media library plugin?
The config is part of spatie-media-library, not the plugin. You can publish it with
php artisan vendor:publish --provider="Spatie\MediaLibrary\MediaLibraryServiceProvider" --tag="medialibrary-config"
php artisan vendor:publish --provider="Spatie\MediaLibrary\MediaLibraryServiceProvider" --tag="medialibrary-config"
13 replies
FFilament
Created by Emmanuel71 on 11/4/2024 in #❓┊help
How to use a custom path with spatie media library plugin?
So in the above example, if your Media Model is linked to a user, you would have something like
'custom_path_generators' => [
User::class => UserMediaPathGenerator::class
],
'custom_path_generators' => [
User::class => UserMediaPathGenerator::class
],
As I said, I haven't tried it but it should work.
13 replies
FFilament
Created by Emmanuel71 on 11/4/2024 in #❓┊help
How to use a custom path with spatie media library plugin?
Personally, I'm using a custom media model (extends the default Spatie media model) and added my own way to override the generated path
13 replies
FFilament
Created by Emmanuel71 on 11/4/2024 in #❓┊help
How to use a custom path with spatie media library plugin?
Spatie has a per-model path generator AFAIK. In the config there's the following section
'custom_path_generators' => [
// Model::class => PathGenerator::class
// or
// 'model_morph_alias' => PathGenerator::class
],
'custom_path_generators' => [
// Model::class => PathGenerator::class
// or
// 'model_morph_alias' => PathGenerator::class
],
I haven't used it but I assume you can define a custom path generator based on the related model that the media is linked to.
13 replies
FFilament
Created by Steff on 11/2/2024 in #❓┊help
Action works fast but modal window hangs?
So if you remove everything after $result = $service->myServiceClass($record->id); the modal remains open?
8 replies
FFilament
Created by ChesterS on 11/1/2024 in #❓┊help
Is it possible to make a custom action behave/look like as submit button?
FWIW, I found a way to do this 1) Add an id to your form
<form id="my-form-id">...</form>
<form id="my-form-id">...</form>
2) Change your action to something like this
public function doSomethingAction(): Action
{
return Action::make('doSomething')
->extraAttributes([
// This is the 'ugly' part. Need to prevent the form from being submitted by default
// so instead we define a method we need to call and pass it to the wire:click attr
'wire:click.prevent' => 'doSomething',
])
->submit('my-form-id') // Your form id goes here
}

public function doSoemething(): void {
$this->validate();

$data = $this->myForm->getState();
...
}
public function doSomethingAction(): Action
{
return Action::make('doSomething')
->extraAttributes([
// This is the 'ugly' part. Need to prevent the form from being submitted by default
// so instead we define a method we need to call and pass it to the wire:click attr
'wire:click.prevent' => 'doSomething',
])
->submit('my-form-id') // Your form id goes here
}

public function doSoemething(): void {
$this->validate();

$data = $this->myForm->getState();
...
}
Not pretty but it works ¯\_(ツ)_/¯ Hope it helps. Let me know if you find a better way please!
4 replies