hxn
hxn
FFilament
Created by hxn on 6/14/2024 in #❓┊help
repeater simple vs schema
Hello, In my model, I have a field named attachments, which is cast as an array. The field can contain multiple path and looks like this:
attachments: "["ticket-attachments\/1715956812\/3v55MYasX2RhfVRoeoaSzdXtzwn9tNKZeNK5vYQz.png","ticket-attachments\/1715956812\/C5Y4cfy3fyiv8XVt7BfKxAXtuztJeWHSDR1GxtcQ.png","ticket-attachments\/1715956812\/suaEW2fieaxAYwONhDn9Oqeo81IWAU4voxEsFr5i.png"]"
attachments: "["ticket-attachments\/1715956812\/3v55MYasX2RhfVRoeoaSzdXtzwn9tNKZeNK5vYQz.png","ticket-attachments\/1715956812\/C5Y4cfy3fyiv8XVt7BfKxAXtuztJeWHSDR1GxtcQ.png","ticket-attachments\/1715956812\/suaEW2fieaxAYwONhDn9Oqeo81IWAU4voxEsFr5i.png"]"
When I use a simple repeater with a ViewField, the $getState() function returns the string path of my images as expected:
Repeater::make('attachments')
->simple(
ViewField::make('attachments')
->view('filament.ticket-attachment'),
)
Repeater::make('attachments')
->simple(
ViewField::make('attachments')
->view('filament.ticket-attachment'),
)
However, when I switch from simple to schema, the $getState() function always returns null:
Repeater::make('attachments')
->schema([
ViewField::make('attachments')
->view('filament.ticket-attachment'),
])
Repeater::make('attachments')
->schema([
ViewField::make('attachments')
->view('filament.ticket-attachment'),
])
Here's the custom view:
<div>
<img class="w-full p-8 mb-4" src="{{ asset('storage/' . $getState()) }}" alt="Attachment">
</div>
<div>
<img class="w-full p-8 mb-4" src="{{ asset('storage/' . $getState()) }}" alt="Attachment">
</div>
By switching to schema, I'm encountering an issue where the state is not being retrieved correctly. Any guidance on resolving this would be greatly appreciated.
4 replies
FFilament
Created by hxn on 3/20/2024 in #❓┊help
Multi dimensional KeyValue
Hello, Is there an easy way to deal with multi dimensional array with the keyvalue component? For now i got a [object Object] in the value. I can't even save the resource because the keyvalue awaiting a ?string Maybe it is possible to ask filament to ignore the values if its an array? Exemple of my data (casted as an array) "{"name": "CompanyName", "address": {"country": "USA", "postcode": "44"}, "status": "ok"}"
7 replies
FFilament
Created by hxn on 10/14/2023 in #❓┊help
conditional table column
Hello i'm trying to make a conditional column.. I've follow this online tutorial to make a settings page https://blog.moonguard.dev/setting-page-with-filament I've made some change to accept media (I'm using curator plugin) and what i want to achieve is a conditional column If the type of my setting is media i want a CuratorColumn. For everything else a TextColumn but i don't know how to make this
return $table
->columns([
Tables\Columns\TextColumn::make('label')
->sortable()
->searchable(),
// If the type is "media" make a CuratorColumn on value
CuratorColumn::make('value')
->circular(),
// Else make a TextColumn on value
Tables\Columns\TextColumn::make('value')
->formatStateUsing(function ($state) {
return match ($state) {
null => 'Empty',
"0" => 'False',
"1" => 'True',
default => 'OK'
};
})
->sortable()
->searchable(),
])
return $table
->columns([
Tables\Columns\TextColumn::make('label')
->sortable()
->searchable(),
// If the type is "media" make a CuratorColumn on value
CuratorColumn::make('value')
->circular(),
// Else make a TextColumn on value
Tables\Columns\TextColumn::make('value')
->formatStateUsing(function ($state) {
return match ($state) {
null => 'Empty',
"0" => 'False',
"1" => 'True',
default => 'OK'
};
})
->sortable()
->searchable(),
])
10 replies
FFilament
Created by hxn on 8/3/2023 in #❓┊help
policies not fully working
Hello, I have a policy with everything on false (create, update, delete, restore, forceDelete) Create button disappear as expected Navigate to resource/1/edit throw forbidden as expected. But i still can bulk delete when selecting the row on the table
3 replies
FFilament
Created by hxn on 7/20/2023 in #❓┊help
Custom page with filament blade component
Hello, I need some help with creating a custom page to export certain model data using Laravel Excel. I want to use the Filament view component to keep things consistent. But I couldn't find any info in documentation on blade components. I just need a simple page where you can choose the model, select the timeframe (today, this week or this month) from a dropdown, and then hit an export button that calls my controller. Or can i just create like a fake "Ressource" page and build it with the table builder? If anyone knows how to do this or has any tips, I'd be super grateful for your input!
4 replies
FFilament
Created by hxn on 5/8/2023 in #❓┊help
Select options not updated when using "create & create another" button
In a RelationManager i'm using
Forms\Components\Select::make('locale')
->required()
->options(fn (RelationManager $livewire) => $livewire->ownerRecord->getUnsetLocales())
Forms\Components\Select::make('locale')
->required()
->options(fn (RelationManager $livewire) => $livewire->ownerRecord->getUnsetLocales())
When using "Create" button all good but when i'm using the "create & create another" button my options isnt updated
8 replies
FFilament
Created by hxn on 5/8/2023 in #❓┊help
Uploaded image not deleted on delete
When deleting a record the image in storage isnt deleted. I've tried something like this but record is protected
->actions([
Tables\Actions\EditAction::make(),
Tables\Actions\DeleteAction::make()
->after(function ($action){
unlink(storage_path('app/public/'. $action->record->image_url));
}),
])
->actions([
Tables\Actions\EditAction::make(),
Tables\Actions\DeleteAction::make()
->after(function ($action){
unlink(storage_path('app/public/'. $action->record->image_url));
}),
])
14 replies