skyrowl
skyrowl
FFilament
Created by skyrowl on 6/6/2024 in #❓┊help
Slow select relationship in a relationship repeater
Hey, I have something like: Event (top record) > Schedules (relationship repeater) > (Pivot) > Product (relationship select) Loading the event record is fast, same as schedules (~ 2-5ms per record) but debugbar tells me that the last relationship takes around 300-500ms per Schedule and per Product Select So if I'm having 5 Schedules it will take 5 * 300 = 1,5sc to load the form at best I don't really know how to optimize that neither what I'm doing wrong, maybe could be the json column as the name attribute ? Could you help me please ? Here's the code of the select
Forms\Components\Select::make('products')
->label('Activité(s)')
->relationship('productsWithoutTrashed')
->getOptionLabelFromRecordUsing(fn (Model $record) => "{$record->attribute_data['title']->getValue()}")
->multiple()
->required()
->placeholder('Sélectionner une activité')
->preload()
->searchable(['attribute_data->title'])
->columnSpan([
'default' => 6,
'lg' => 3,
]),
Forms\Components\Select::make('products')
->label('Activité(s)')
->relationship('productsWithoutTrashed')
->getOptionLabelFromRecordUsing(fn (Model $record) => "{$record->attribute_data['title']->getValue()}")
->multiple()
->required()
->placeholder('Sélectionner une activité')
->preload()
->searchable(['attribute_data->title'])
->columnSpan([
'default' => 6,
'lg' => 3,
]),
2 replies
FFilament
Created by skyrowl on 6/5/2024 in #❓┊help
Use requiresConfirmation on modal form
Hey, I'm searching for a way to use requiresConfirmation with a modal form I'm using the form to use a range to delete models The requiresConfirmation has no effect on the static action I tried replacing the static action with a plain action but I'm struggling to pass the form datas Could you help me figure this out please ?
8 replies
FFilament
Created by skyrowl on 5/24/2024 in #❓┊help
Use reactive props in widgets of a panel page
Hi, I'm trying to build a page within the panel with reactive properties like the following
class AnalyticsDashboard extends Page
{
#[Reactive]
public array $metrics = [];

#[On('updateFilters')]
public function updateData()
{
$dataset = $this->getData();

$this->metrics = Arr::get($dataset, 'metrics', []);
}

public function getWidgetData(): array
{
return [
'metrics' => $this->metrics,
];
}
...
}
class AnalyticsDashboard extends Page
{
#[Reactive]
public array $metrics = [];

#[On('updateFilters')]
public function updateData()
{
$dataset = $this->getData();

$this->metrics = Arr::get($dataset, 'metrics', []);
}

public function getWidgetData(): array
{
return [
'metrics' => $this->metrics,
];
}
...
}
When "updateFilters" event is dispatched I get the following error Cannot mutate reactive prop [metrics] in component: [app.filament.pages.analytics-dashboard] I need to mention that I tested without any widget and still get the error, the property is not mutated from the action or anywhere else than from the Page's livewire component Another thing is that I'm using Octane and unsure if it tampers livewire data but can't find anything recent or any issue opened about this so I don't really know Last trace is the following (why I thought about octane) Livewire \ Features \ SupportReactiveProps \ BaseReactive : 40 dehydrate
public function dehydrate($context)
{
if ($this->originalValueHash !== crc32(json_encode($this->getValue()))) {
>> throw new CannotMutateReactivePropException($this->component->getName(), $this->getName());
}

$context->pushMemo('props', $this->getName());

}
public function dehydrate($context)
{
if ($this->originalValueHash !== crc32(json_encode($this->getValue()))) {
>> throw new CannotMutateReactivePropException($this->component->getName(), $this->getName());
}

$context->pushMemo('props', $this->getName());

}
2 replies
FFilament
Created by skyrowl on 5/20/2024 in #❓┊help
Pass PHP variables in RawJs object
Hey, I'm wishing to pass PHP variables in a RawJs object but there's very few docs about this, is it possible ?
2 replies
FFilament
Created by skyrowl on 4/29/2024 in #❓┊help
distinct() on Builder blocks
Hey, I saw that on Repeater field it's possible to use the distinct rule wherehas it's not on Builder It's pretty similar and there are cases where we have a repeated field in every blocks (identifier for example) The code for this rule on Builder would be the same except that we also check if the instance is a Builder Is there any reason why it's limited to Repeater field ?
2 replies
FFilament
Created by skyrowl on 11/14/2023 in #❓┊help
Dynamic mask input is not dynamic
Hey working with the text field and putting it a dynamic mask for money as shown below, tho the mask is not dynamic at all, I can write whatever I want in that field and only once I leave focus the field will update to the mask Is there anything I'm missing on dynamic masks ? my reference is the doc of Alpine on dynamic masks and it works like a charm there but I can't figure out why it's not in my Filament
Forms\Components\TextInput::make('price')
->columnSpan(['default' => 2])
->placeholder('0.00')
->mask(RawJs::make(<<<'JS'
$money($input, '.', ' ')
JS))
->numeric()
->inputMode('decimal')
->required()
Forms\Components\TextInput::make('price')
->columnSpan(['default' => 2])
->placeholder('0.00')
->mask(RawJs::make(<<<'JS'
$money($input, '.', ' ')
JS))
->numeric()
->inputMode('decimal')
->required()
2 replies
FFilament
Created by skyrowl on 11/14/2023 in #❓┊help
Mutate data on relation manager
Hey, I'm wishing to mutate data on the relation manager like on the edit or create page because I have some fields that can't be used as is Is there any way to do it like in pages of resources but inside the relation manager by any way ?
4 replies
FFilament
Created by skyrowl on 10/17/2023 in #❓┊help
Finding a way to apply translations to nested JSON
Hey, I was wondering if there was any way to apply translations to nested JSON using the Spatie Translatable plugin Basically I want to apply the translations to a builder block, I was thinking of two ways like using a custom field that could sync with the plugin or using a custom data model attached to the block if possible where translations attribute correspond to the block I don't really know how to proceed and I'll be glad if anyone could help me through this
1 replies
FFilament
Created by skyrowl on 10/10/2023 in #❓┊help
Alpine component not loaded
Hey, I'm using Curator plugin and their resource included is using their Curator field that loads an Alpine component Problem is that every other plugin using JS files are loaded except this alpine component even tho assets have been published using filament artisan command There is no errors in the console and the script is never loaded watching at the browser dev console (network tab), the plugin do have the alpine directives to load the module but it's still not there Is there any other step I'm missing in filament to load Alpine components ?
81 replies
FFilament
Created by skyrowl on 6/21/2023 in #❓┊help
Unique rule on a repeater stored in json
Hey, I was wondering if it's possible to apply a unique rule on a field in a repeater that is not a relationship but stored in json instead ? A little example would be: Repeater: -> Text field: name -> Text field: unique_value Where unique_value will compare to every other Repeater block to check if the value is taken
3 replies
FFilament
Created by skyrowl on 6/2/2023 in #❓┊help
Add stancl/tenancy to forms
Hey as filament admin is usable with tenancy through middleware, is there any way to do it with forms as well ? I didn't find anything in config files and Rich Editor attachments defaults to the central storage helper so it gives the wrong link
13 replies
FFilament
Created by skyrowl on 6/1/2023 in #❓┊help
Check dirty state of a form
Hey, is there any way to check if a form is dirty ? I need to check the form in its entirety and not only a single field so I can't call variables of the page
22 replies
FFilament
Created by skyrowl on 5/11/2023 in #❓┊help
Use custom action buttons on repeater/builder
Hey, I was wondering if there's any way other than creating a new form field to customize action buttons on Repeater and Builder ? My use case is that I need to disable deletion on some items according to the model datas, if anyone could help me I'd greatly appreciate it!
3 replies
FFilament
Created by skyrowl on 4/27/2023 in #❓┊help
Filament Spatie media input doesn't show image or return an error
Hey, so I have 2 conversions registered on my model, one is called 'small', one is 'default' Problem is that when the component is registered, it doesn't display any image with the only parameters ->imageCropAspectRatio('16:9')->collection('thumbnail') When I add the parameter ->conversion('default') it throws me this error Call to a member function hasGeneratedConversion() on null Files are registered in the DB and stored on the disk but it still does this, I don't really understand why if someone is able to tell me please?
2 replies
FFilament
Created by skyrowl on 4/26/2023 in #❓┊help
Query JSON columns in filament tables
Hey, is it possible to query JSON columns in tables ? I've been trying multiple things like ->, ., [] without any succes Is it possible to do something like this Tables\Columns\TextColumn::make('attribute_data->name->value') ?
15 replies
FFilament
Created by skyrowl on 4/20/2023 in #❓┊help
How to change database connection of filament tables and forms
Hey, I'm wondering if there is any way to change the database connection ? Basically default connection is X and on a page I want to access connection Y that is another DB to display datas that are stored there only, I have the connection but don't really know how to pass it to filament tables/forms
42 replies
FFilament
Created by skyrowl on 3/27/2023 in #❓┊help
Handle tenancy on specific tabs/resources
Hey, I have an application running that I would like to put on stancl/tenancy Basically all the users will have access to profile/subscription/etc... on the central domain in a filament dashboard (only located on the central domain) What I'd like to do is put users and their settings on the main database and using stancl/tenancy for them to manage their store for example, what can I do to handle the use of multi db tenancy on products tab only to populate data in filament resources ?
6 replies