Garrita
Garrita
FFilament
Created by Garrita on 10/24/2024 in #❓┊help
Get state from form to createOptionForm
I want to get the person_type state from the form to the createOptionForm modal, I've tried $get('../person_type') or '../../' but it does not work.
Radio::make('person_type')
->label(__('Person Type'))
->options(PersonType::class)
->default(PersonType::Natural)
->formatStateUsing(fn (?Dealer $record) => $record?->person_type ?? PersonType::Natural)
->live(),

Select::make('user_id')
->label(__('User'))
->relationship(
name: 'user',
titleAttribute: 'name',
modifyQueryUsing: fn ($query) => $query->whereDoesntHave('dealer'),
ignoreRecord: true
)
->getOptionLabelFromRecordUsing(fn (User $user) => $user->name.' - '.($user->email ?? $user->phone))
->native(false)
->searchable()
->preload()
->createOptionForm([
TextInput::make('name')
->label(function (Get $get) {
return $get('../person_type') === PersonType::Natural ? __('Name') : __('Company Name');
})
->required(),
]);
Radio::make('person_type')
->label(__('Person Type'))
->options(PersonType::class)
->default(PersonType::Natural)
->formatStateUsing(fn (?Dealer $record) => $record?->person_type ?? PersonType::Natural)
->live(),

Select::make('user_id')
->label(__('User'))
->relationship(
name: 'user',
titleAttribute: 'name',
modifyQueryUsing: fn ($query) => $query->whereDoesntHave('dealer'),
ignoreRecord: true
)
->getOptionLabelFromRecordUsing(fn (User $user) => $user->name.' - '.($user->email ?? $user->phone))
->native(false)
->searchable()
->preload()
->createOptionForm([
TextInput::make('name')
->label(function (Get $get) {
return $get('../person_type') === PersonType::Natural ? __('Name') : __('Company Name');
})
->required(),
]);
1 replies
FFilament
Created by Garrita on 9/13/2024 in #❓┊help
Save Spatie Media Library File in Relationship
I have a form resource where I save the child and the parent but when I try to save the files for the parent it does not store them, just the other attributes except the files. Models: AuctionCar belongsTo Car AuctionCarResource.php In this case, I save the mileage and the license plate for the parent, but it does not save the images.
Group::make()
->relationship('car')
->schema([
TextInput::make('mileage')
->label(__('Mileage'))
->numeric()
->suffix(__('km.'))
->required(),

TextInput::make('license_plate')
->label(__('License Plate'))
->unique('cars', 'license_plate', ignoreRecord: true)
->live()
->afterStateUpdated(function (HasForms $livewire, TextInput $component) {
$livewire->validateOnly($component->getStatePath());
})
->required(),

SpatieMediaLibraryFileUpload::make('images')
->label(__('Images'))
->multiple()
->image()
->required(),
])
->columns(3)`
->columnSpan(3),
Group::make()
->relationship('car')
->schema([
TextInput::make('mileage')
->label(__('Mileage'))
->numeric()
->suffix(__('km.'))
->required(),

TextInput::make('license_plate')
->label(__('License Plate'))
->unique('cars', 'license_plate', ignoreRecord: true)
->live()
->afterStateUpdated(function (HasForms $livewire, TextInput $component) {
$livewire->validateOnly($component->getStatePath());
})
->required(),

SpatieMediaLibraryFileUpload::make('images')
->label(__('Images'))
->multiple()
->image()
->required(),
])
->columns(3)`
->columnSpan(3),
17 replies
FFilament
Created by Garrita on 6/13/2024 in #❓┊help
Error when switching tabs in Relation Manager
I have two relationship manager and it only works when I refresh the entire page but not when I switch between them, what could happen?
5 replies
FFilament
Created by Garrita on 4/4/2024 in #❓┊help
Select Relationship Modify Query Using
Hi everyone, When I create an auction I select a car but the dropdown only shows the cars that don't belongs to another auction (I use modifyQueryUsing), so this works when I create. The issue is when I try to update an auction, I cannot see my car selected in the dropdown list because that car already belongs to the same auction that I'm updating so how can I fix that?
Select::make('car_id')
->label('Car')
->relationship(
name: 'car',
titleAttribute: 'name',
modifyQueryUsing: fn (Builder $query) => $query->whereDoesntHave('auction')
)
->required(),
Select::make('car_id')
->label('Car')
->relationship(
name: 'car',
titleAttribute: 'name',
modifyQueryUsing: fn (Builder $query) => $query->whereDoesntHave('auction')
)
->required(),
8 replies
FFilament
Created by Garrita on 11/7/2023 in #❓┊help
Summarize in a custom column
Hi guys, how can I summarize this value as a total of a custom column?
TextColumn::make('available_amount')
->summarize(Sum::make())
->label('Monto Disponible')
->state(function (Model $record) {
return $record->availableAmount();
})
TextColumn::make('available_amount')
->summarize(Sum::make())
->label('Monto Disponible')
->state(function (Model $record) {
return $record->availableAmount();
})
I got an error that my table does not find the available_amount column because I know that it's generated.
2 replies