Robin
Robin
FFilament
Created by Robin on 6/19/2024 in #❓┊help
Relationmanager update rooted relations
Hello, I'm trying to figure out how to save related attributes in a relation manager. In first instance, I had to write a new table query, because the one given by Filament by default doesn't give me the correct items. The function looks like this;
protected function getTableQuery(): Builder
{
return ActionsUsers::query()
->withoutGlobalScopes()
->leftJoin('actions', 'actions.id', '=', 'actions_users.action_id')
->where('actions.device_id', '=', $this->getOwnerRecord()->id)
->with([
'action',
'action.area',
'action.property',
'action.virtualDevice',
'user',
'action.device',
]);
}
protected function getTableQuery(): Builder
{
return ActionsUsers::query()
->withoutGlobalScopes()
->leftJoin('actions', 'actions.id', '=', 'actions_users.action_id')
->where('actions.device_id', '=', $this->getOwnerRecord()->id)
->with([
'action',
'action.area',
'action.property',
'action.virtualDevice',
'user',
'action.device',
]);
}
Now, I get the correct data, but when I try to do things like this:
TextInput::make('action.virtualDevice.http_host')
->label('HTTP host')
->helperText('Do not end with a /')
->formatStateUsing(fn(ActionsUsers $record) => $record->action->virtualDevice?->endpoint)
->default(null),
TextInput::make('action.virtualDevice.http_host')
->label('HTTP host')
->helperText('Do not end with a /')
->formatStateUsing(fn(ActionsUsers $record) => $record->action->virtualDevice?->endpoint)
->default(null),
I need to set the formatStateUsing, else it doesn't give any kind of values. When saving, I get nothing but exceptions when trying to save and the table it tries to save is also wrong. How can I resolve this issue?
2 replies
FFilament
Created by Robin on 4/15/2024 in #❓┊help
Add custom events to plugin
Hello, I don't seem to see a way to add custom events (queued or not) to a plugon. Anyone who can guide me with this?
10 replies
FFilament
Created by Robin on 9/2/2023 in #❓┊help
Error in FilamentSpatieRolesPermissionsServiceProvider after upgrade
I've upgraded from v2 to v3, but I get Class "Filament\PluginServiceProvider" not found is there anything I'm doing wrong?
4 replies
FFilament
Created by Robin on 9/1/2023 in #❓┊help
Bulk actions always displaying
No description
9 replies
FFilament
Created by Robin on 8/31/2023 in #❓┊help
Running an action before fetch of a resource
Is it possible to execute code before a resource gets fetched from the database? so like every time the resource gets called, I want to do some other code first.
3 replies
FFilament
Created by Robin on 8/22/2023 in #❓┊help
Livewire/filament bug?
I all of a sudden encounter; Livewire\Exceptions\CorruptComponentPayloadException POST /livewire/message/app.filament.resources.vending-machine-resource.pages.view-vending-machine Livewire encountered corrupt data when trying to hydrate the [app.filament.resources.vending-machine-resource.pages.view-vending-machine] component. Ensure that the [name, id, data] of the Livewire component wasn't tampered with between requests. When opening an action modal. I didn't update anything on the page. I'm on the latest version of filament v2.
8 replies
FFilament
Created by Robin on 8/11/2023 in #❓┊help
Fill a selectbox it's option on edit when loaded from relationmanagers
I'm trying to get a relation manager to fill a selectbox that is a couple of relations "away" from the record. This is what I currently have;
Forms\Components\Select::make('product')
->label('Product')
->searchable()
->default(fn(VendingMachineSlot $record) => $record->sellingPointProduct->product->id)
->getSearchResultsUsing(function (RelationManager $livewire, string $search) {
/** @var VendingMachine $ownerRecord */
$ownerRecord = $livewire->ownerRecord;
return $ownerRecord
->sellingPoint
->zone
->zoneProducts()
->join('products', 'product_id', '=', 'products.id')
->where('products.name', 'like', "%$search%")
->select('zones_products.id', 'zones_products.product_id', 'products.name', 'products.id')
->limit(50)
->pluck('product.name', 'product.id');
})
->required(),
Forms\Components\Select::make('product')
->label('Product')
->searchable()
->default(fn(VendingMachineSlot $record) => $record->sellingPointProduct->product->id)
->getSearchResultsUsing(function (RelationManager $livewire, string $search) {
/** @var VendingMachine $ownerRecord */
$ownerRecord = $livewire->ownerRecord;
return $ownerRecord
->sellingPoint
->zone
->zoneProducts()
->join('products', 'product_id', '=', 'products.id')
->where('products.name', 'like', "%$search%")
->select('zones_products.id', 'zones_products.product_id', 'products.name', 'products.id')
->limit(50)
->pluck('product.name', 'product.id');
})
->required(),
Now the error I got is {closure}(): Argument #1 ($record) must be of type App\Models\VendingMachineSlot, null given (default item in the above code) What I need it the selectbox to be filled (and show the item selected) that is found in $record->sellingPointProduct->product->id in where $record should be the "edit" model for the selected relation manager object. Anyone an idea on what and how to do this? Thanks in advance! ❤️
3 replies
FFilament
Created by Robin on 8/10/2023 in #❓┊help
Notifications reduction of amount of showed notifications
Is it possible to (simply) reduce the amount of showed notifications in the sidebar? I'd like to only show the unread notifications or the notifications that are seen but then a cutoff in creation age of like 1 week or so. Is this possible and how?
17 replies
FFilament
Created by Robin on 6/14/2023 in #❓┊help
Set state for enum
How can I get the selected value for a select column when the date is filled from an enum?
Forms\Components\Select::make('type')->options(VendingMachineType::toAssociativeArray())
Forms\Components\Select::make('type')->options(VendingMachineType::toAssociativeArray())
the enum data returns;
[1 => 'item 1', 2 => 'item 2']
[1 => 'item 1', 2 => 'item 2']
37 replies
FFilament
Created by Robin on 5/28/2023 in #❓┊help
icon for false table icons not showing
4 replies
FFilament
Created by Robin on 5/4/2023 in #❓┊help
Morphed table not filling in form
I don't seem to be able to fill the value of a morphed column in the formview. I have the following relation;
public function sellingPoint(): MorphOne
{
return $this->morphOne(SellingPoint::class, 'morph');
}
public function sellingPoint(): MorphOne
{
return $this->morphOne(SellingPoint::class, 'morph');
}
When I try to access this inside a form, it never gets filled with a value. I try to access ti this way;
Forms\Components\TextInput::make('sellingPoint.name')
->reactive()
->afterStateUpdated(function (?VendingMachine $record, $state) {
$record?->sellingPoint?->update([
'name' => $state
]);
}),
Forms\Components\TextInput::make('sellingPoint.name')
->reactive()
->afterStateUpdated(function (?VendingMachine $record, $state) {
$record?->sellingPoint?->update([
'name' => $state
]);
}),
Then the input field never gets it's value. However saving works (due to that after state updated callback). In the table view it works just fine;
Tables\Columns\TextColumn::make('sellingPoint.name')->label('Name')->searchable(),
Tables\Columns\TextColumn::make('sellingPoint.name')->label('Name')->searchable(),
What am I missing here?
8 replies
FFilament
Created by Robin on 4/21/2023 in #❓┊help
How to get the same form select in the inline table structure?
Hello, I'm trying to get this inline inside a table. Any idea how I can achieve this?
Forms\Components\Select::make('product_id')
->label('Product')
->searchable()
->getSearchResultsUsing(function (RelationManager $livewire, string $search) {
/** @var VendingMachine $ownerRecord */
$ownerRecord = $livewire->ownerRecord;

return $ownerRecord
->sellingPoint
->zone
->zoneProducts()
->join('products', 'product_id', '=', 'products.id')
->where('products.name', 'like', "%$search%")
->select('zones_products.id', 'zones_products.product_id', 'products.name', 'products.id')
->limit(50)
->pluck('product.name', 'product.id');
}),
Forms\Components\Select::make('product_id')
->label('Product')
->searchable()
->getSearchResultsUsing(function (RelationManager $livewire, string $search) {
/** @var VendingMachine $ownerRecord */
$ownerRecord = $livewire->ownerRecord;

return $ownerRecord
->sellingPoint
->zone
->zoneProducts()
->join('products', 'product_id', '=', 'products.id')
->where('products.name', 'like', "%$search%")
->select('zones_products.id', 'zones_products.product_id', 'products.name', 'products.id')
->limit(50)
->pluck('product.name', 'product.id');
}),
2 replies
FFilament
Created by Robin on 3/29/2023 in #❓┊help
Mutate relation data before save
I'm trying to mutate my data of a relationmanager before I save the records (attach). The attach should get an extra parameter of the 'parent' in the relation that has some data, so I can save/mutate the data. It should also hook into another function so that I can update other data. For example; In the relation manager I have this;
Tables\Actions\AttachAction::make()->preloadRecordSelect()->beforeFormFilled(function (array $data) {
dd($data);
}),
Tables\Actions\AttachAction::make()->preloadRecordSelect()->beforeFormFilled(function (array $data) {
dd($data);
}),
I don't see any DD being triggered here. I want, when the user presses attach, that there is data being added to the attaching object. Plus that there is another function that is being called to "sync" other data. Any ideas?
7 replies
FFilament
Created by Robin on 3/10/2023 in #❓┊help
Dynamic save for form relation ship
Hi, I wonder how I can make sure that the relationship gets "saved" but still keep reactivity to handle another task. How can I achieve this? Example code:
Fieldset::make('Power')
->relationship('state')
->schema([
Select::make('requested_power')->label('Power input request')
->reactive()
->afterStateUpdated(function (?Model $record, $state) {
/* @var Device $record */
$this->getMQTTBroker()->publish(new SetInputPowerMessage($record, $state));
})
->options([
'0' => 'Fixed 5V@5A',
'1' => 'Fixed 9V@5A',
'2' => 'Fixed 12V@5A',
'3' => 'Fixed 15V@5A',
'4' => 'Fixed 20V@5A',
]),
])->columns(3),
Fieldset::make('Power')
->relationship('state')
->schema([
Select::make('requested_power')->label('Power input request')
->reactive()
->afterStateUpdated(function (?Model $record, $state) {
/* @var Device $record */
$this->getMQTTBroker()->publish(new SetInputPowerMessage($record, $state));
})
->options([
'0' => 'Fixed 5V@5A',
'1' => 'Fixed 9V@5A',
'2' => 'Fixed 12V@5A',
'3' => 'Fixed 15V@5A',
'4' => 'Fixed 20V@5A',
]),
])->columns(3),
I also want to get the record, not the relation inside the afterStateUpdated
2 replies
FFilament
Created by Robin on 3/3/2023 in #❓┊help
Action on change of input
26 replies