DanielvdSpoel
DanielvdSpoel
FFilament
Created by DanielvdSpoel on 3/15/2025 in #❓┊help
Relationship select executes distinct query that doesn't support having JSON columns
Pretty easy, we have a products table that has a json field. And it has a relation to itselfs. We use this select:
Forms\Components\Select::make('upsells_data')
->relationship('upsells', 'name')
->maxItems(5)
->multiple()
->preload()
->searchable(),
Forms\Components\Select::make('upsells_data')
->relationship('upsells', 'name')
->maxItems(5)
->multiple()
->preload()
->searchable(),
but we get this error:
SQLSTATE[42883]: Undefined function: 7 ERROR: could not identify an equality operator for type json LINE 1: select distinct "products".* from "products" left join "prod... ^
select
distinct "products".*
from
"products"
left join "product_upsells" on "products"."id" = "product_upsells"."upsell_id"
where
"products"."deleted_at" is null
order by
"products"."name" asc
SQLSTATE[42883]: Undefined function: 7 ERROR: could not identify an equality operator for type json LINE 1: select distinct "products".* from "products" left join "prod... ^
select
distinct "products".*
from
"products"
left join "product_upsells" on "products"."id" = "product_upsells"."upsell_id"
where
"products"."deleted_at" is null
order by
"products"."name" asc
wondering how i could fix this issue
2 replies
FFilament
Created by DanielvdSpoel on 3/2/2025 in #❓┊help
Get file name from state update call
is there a way to get the origional file? the state object contains the random generated name
Forms\Components\FileUpload::make('file')
->label(__('labels.file'))
->directory('documents')
->afterStateUpdated(function ($state, Forms\Get $get) {
ray($get('file_name')); //null
ray($state);
})
->disk('local')
->storeFileNamesIn('file_name')
->required(fn(string $operation) => $operation === 'create')
->columnSpanFull(),
Forms\Components\FileUpload::make('file')
->label(__('labels.file'))
->directory('documents')
->afterStateUpdated(function ($state, Forms\Get $get) {
ray($get('file_name')); //null
ray($state);
})
->disk('local')
->storeFileNamesIn('file_name')
->required(fn(string $operation) => $operation === 'create')
->columnSpanFull(),
2 replies
FFilament
Created by DanielvdSpoel on 12/18/2024 in #❓┊help
Blackout screen on search/click on actions
I get this error when trying to search or use an attach action:
VM339:21 Uncaught TypeError: Cannot read properties of undefined (reading 'dispatchEvent')
at eval (eval at <anonymous> (module.esm.js:488:19), <anonymous>:21:43)
at module.esm.js:859:7
at $r (module.esm.js:867:21)
at module.esm.js:854:7
VM339:21 Uncaught TypeError: Cannot read properties of undefined (reading 'dispatchEvent')
at eval (eval at <anonymous> (module.esm.js:488:19), <anonymous>:21:43)
at module.esm.js:859:7
at $r (module.esm.js:867:21)
at module.esm.js:854:7
Versions: filament/filament 3.2.131 livewire/livewire 3.5.12 Does anyone know why this is happening?
2 replies
FFilament
Created by DanielvdSpoel on 12/11/2024 in #❓┊help
Notification action not working
Notification::make()
->title('Copy your token')
->body('Make sure to copy your new token now. You won\'t be able to see it again.')
->persistent()
->success()
->actions([
Action::make('copy')
->button()
->icon('heroicon-o-clipboard-document')
->action(function ($livewire) use ($plainTextToken) {
dd($plainTextToken);
ray('plainTextToken', $plainTextToken);
$livewire->js(
'window.navigator.clipboard.writeText("' . $plainTextToken . '");
$tooltip("' . __('Copied to clipboard') . '", { timeout: 1500 });'
);
}),
])
->send();
Notification::make()
->title('Copy your token')
->body('Make sure to copy your new token now. You won\'t be able to see it again.')
->persistent()
->success()
->actions([
Action::make('copy')
->button()
->icon('heroicon-o-clipboard-document')
->action(function ($livewire) use ($plainTextToken) {
dd($plainTextToken);
ray('plainTextToken', $plainTextToken);
$livewire->js(
'window.navigator.clipboard.writeText("' . $plainTextToken . '");
$tooltip("' . __('Copied to clipboard') . '", { timeout: 1500 });'
);
}),
])
->send();
Nothing get's executed when the button is clicked, does anyone know why?
4 replies
FFilament
Created by DanielvdSpoel on 10/5/2024 in #❓┊help
File upload not working with zip files
No description
3 replies
FFilament
Created by DanielvdSpoel on 8/30/2024 in #❓┊help
Typing of getOwnerRecord and Filament::getTenant()
I'm currently using larastan to make sure my code is clean and fully typed, but i find myself to have to do a lot of code comments to make sure the code is properly typed both for my editor and larastan. I'm talking about stuff like this:
->hidden(function (RelationManager $livewire) {
/** @var Product $product */
$product = $livewire->getOwnerRecord();
return $product->packages->count() < 2;
})
->hidden(function (RelationManager $livewire) {
/** @var Product $product */
$product = $livewire->getOwnerRecord();
return $product->packages->count() < 2;
})
and
Actions\CreateAction::make()
->hidden(function () {
/** @var Organization $organization */
$organization = Filament::getTenant();
Actions\CreateAction::make()
->hidden(function () {
/** @var Organization $organization */
$organization = Filament::getTenant();
is there any way to improve this, and be able to directly used Filament::getTenant and have it typed?
3 replies
FFilament
Created by DanielvdSpoel on 8/1/2024 in #❓┊help
Manually getting media
The upload and table column work great, but now I want to grab the thumbnail to use in a controller, but I have no way of knowing what is the thumbnail. Since there can be multiple media files connected to an model. How do I do this?
2 replies
FFilament
Created by DanielvdSpoel on 6/16/2024 in #❓┊help
Actions
What would be the best way to define a function that can be used as a bulk action, table action and page action? Do i need 3 seperate action classes?
3 replies
FFilament
Created by DanielvdSpoel on 6/8/2024 in #❓┊help
Eager loading relationships in table
I currently have this piece of code:
public static function table(Table $table): Table
{
return $table
->columns([
Tables\Columns\TextColumn::make('last_name')
->label(__('labels.name'))
->getStateUsing(fn(Volunteer $record) => $record->person->fullName())
->sortable()
->searchable(['person.first_name', 'person.middle_name', 'person.last_name']),
Tables\Columns\TextColumn::make('person.email')
->label(__('labels.email'))
->sortable()
->searchable(),
Tables\Columns\TextColumn::make('function')
->label(__('labels.function'))
->sortable()
->searchable(),
])
->modifyQueryUsing(fn(Builder $query) => $query->with('person'))
public static function table(Table $table): Table
{
return $table
->columns([
Tables\Columns\TextColumn::make('last_name')
->label(__('labels.name'))
->getStateUsing(fn(Volunteer $record) => $record->person->fullName())
->sortable()
->searchable(['person.first_name', 'person.middle_name', 'person.last_name']),
Tables\Columns\TextColumn::make('person.email')
->label(__('labels.email'))
->sortable()
->searchable(),
Tables\Columns\TextColumn::make('function')
->label(__('labels.function'))
->sortable()
->searchable(),
])
->modifyQueryUsing(fn(Builder $query) => $query->with('person'))
When trying to search i get the error "SQLSTATE[42P01]: Undefined table: 7 ERROR: missing FROM-clause entry for table "person" LINE 1: ...nt(*) as aggregate from "volunteers" where (lower(person.fir... ^" Does anyone have an insight in how i might fix this? I thought the $query->with() would already solve it but unfortuantly it doesn't
14 replies
FFilament
Created by DanielvdSpoel on 5/19/2024 in #❓┊help
Define tenant in PestPHP test
I'm writing a test to check if it can render my list page, i'm using this code:
it('can render the index page', function () {
livewire(ListAccounts::class, [
'tenant' => $this->household,
])
->assertSuccessful();
})->group('index', 'page', 'resource');
it('can render the index page', function () {
livewire(ListAccounts::class, [
'tenant' => $this->household,
])
->assertSuccessful();
})->group('index', 'page', 'resource');
But i'm getting this error:
Illuminate\Routing\Exceptions\UrlGenerationException: Missing required parameter for [Route: filament.household.resources.accounts.index] [URI: {tenant}/accounts] [Missing parameter: tenant].
Illuminate\Routing\Exceptions\UrlGenerationException: Missing required parameter for [Route: filament.household.resources.accounts.index] [URI: {tenant}/accounts] [Missing parameter: tenant].
does anyone know the right way of providing the tenant?
4 replies
FFilament
Created by DanielvdSpoel on 5/18/2024 in #❓┊help
Filament::getTenant() has no such method
The getTenant method returns a generic type object which ofcourse doesn't have the same methods as my tenant model, is there any way to tell my IDE/PHPStan that those methods do exists? Example:
$rule->where('household_id', Filament::getTenant()?->id);
$rule->where('household_id', Filament::getTenant()?->id);
Error that i get: 51 Access to an undefined property Illuminate\Database\Eloquent\Model::$id.
5 replies
FFilament
Created by DanielvdSpoel on 1/12/2024 in #❓┊help
Multi select relationship complaining about json?
I have this component:
Select::make('related_products')
->label('Related Products')
->relationship('products', 'name')
->preload()
->multiple()
->searchable(),
Select::make('related_products')
->label('Related Products')
->relationship('products', 'name')
->preload()
->multiple()
->searchable(),
But i get this error: https://flareapp.io/share/x5MZXKem name is not json, so i have no clue what's going wrong
3 replies
FFilament
Created by DanielvdSpoel on 1/5/2024 in #❓┊help
500 error on production
I get the following error after a V2 -> V3 upgrade on production, local is fine:
Unable to locate a class or view for component [filament-support::loading-indicator]. (View: /home/kwekerijvh/kwekerijvh.nl/vendor/filament/support/resources/views/components/button.blade.php) (View: /home/kwekerijvh/kwekerijvh.nl/vendor/filament/support/resources/views/components/button.blade.php) (View: /home/kwekerijvh/kwekerijvh.nl/vendor/filament/support/resources/views/components/button.blade.php) (View: /home/kwekerijvh/kwekerijvh.nl/vendor/filament/support/resources/views/components/button.blade.php) (View: /home/kwekerijvh/kwekerijvh.nl/vendor/filament/support/resources/views/components/button.blade.php) (View: /home/kwekerijvh/kwekerijvh.nl/vendor/filament/support/resources/views/components/button.blade.php)
Unable to locate a class or view for component [filament-support::loading-indicator]. (View: /home/kwekerijvh/kwekerijvh.nl/vendor/filament/support/resources/views/components/button.blade.php) (View: /home/kwekerijvh/kwekerijvh.nl/vendor/filament/support/resources/views/components/button.blade.php) (View: /home/kwekerijvh/kwekerijvh.nl/vendor/filament/support/resources/views/components/button.blade.php) (View: /home/kwekerijvh/kwekerijvh.nl/vendor/filament/support/resources/views/components/button.blade.php) (View: /home/kwekerijvh/kwekerijvh.nl/vendor/filament/support/resources/views/components/button.blade.php) (View: /home/kwekerijvh/kwekerijvh.nl/vendor/filament/support/resources/views/components/button.blade.php)
already tried php artisan optimize:clear
5 replies
FFilament
Created by DanielvdSpoel on 11/13/2023 in #❓┊help
Select required validations fails while it's set?
I have a wizard component, where the second step is dynamic based on a select from the first step, Code that returns the fields:
public static function getSettings(): array
{
return [
Select::make('settings.datasets')
->label(__('labels.datasets'))
->options(Dataset::pluck('name', 'id'))
->required()
->searchable(),
Select::make('settings.interaction_list')
->label(__('labels.interaction_list'))
->options(InteractionList::pluck('name', 'id'))
->helperText(__('filament.resources.tasks.interaction_list_helper'))
->searchable(),
TextInput::make('settings.similarity')
->label(__('labels.similarity_threshold'))
->suffix('%')
->numeric()
->step(1)
->minValue(0)
->maxValue(100)
->required()
->default(75),
TextInput::make('settings.min_cluster_size')
->label(__('labels.min_cluster_size'))
->suffix(__('labels.items'))
->numeric()
->step(1)
->required()
->minValue(1)
->default(2),
TextInput::make('settings.cluster_report_name') //todo make unique
->label(__('labels.cluster_report_name'))
->required()
->default('Cluster Report'),

];
}
public static function getSettings(): array
{
return [
Select::make('settings.datasets')
->label(__('labels.datasets'))
->options(Dataset::pluck('name', 'id'))
->required()
->searchable(),
Select::make('settings.interaction_list')
->label(__('labels.interaction_list'))
->options(InteractionList::pluck('name', 'id'))
->helperText(__('filament.resources.tasks.interaction_list_helper'))
->searchable(),
TextInput::make('settings.similarity')
->label(__('labels.similarity_threshold'))
->suffix('%')
->numeric()
->step(1)
->minValue(0)
->maxValue(100)
->required()
->default(75),
TextInput::make('settings.min_cluster_size')
->label(__('labels.min_cluster_size'))
->suffix(__('labels.items'))
->numeric()
->step(1)
->required()
->minValue(1)
->default(2),
TextInput::make('settings.cluster_report_name') //todo make unique
->label(__('labels.cluster_report_name'))
->required()
->default('Cluster Report'),

];
}
18 replies
FFilament
Created by DanielvdSpoel on 11/6/2023 in #❓┊help
Relation column search
I have the following column:
Tables\Columns\TextColumn::make('person.full_name')
->searchable(['person.first_name', 'person.last_name'])
->label(__('labels.name'))
->sortable(),
Tables\Columns\TextColumn::make('person.full_name')
->searchable(['person.first_name', 'person.last_name'])
->label(__('labels.name'))
->sortable(),
I know this is propably a bit of a stretch, but i would like this to work, instead i'm getting this error: https://flareapp.io/share/dPbWEeX7
4 replies
FFilament
Created by DanielvdSpoel on 11/6/2023 in #❓┊help
Filament ignoring foreign key constraints
Pretty simple, i have a foreign key constraint on a table, but filament is able to delete records i'm not allowed to delete in the database? Is there some sort of option I need to enable?
15 replies
FFilament
Created by DanielvdSpoel on 10/18/2023 in #❓┊help
Checklist not sorted correctly
I have this code:
CheckboxList::make('days')
->label('Standaard beschikbaarheid')
->relationship('days', 'name', function (Builder $query) {
return $query->orderBy('day_of_week');
})
->getOptionLabelFromRecordUsing(fn (Model $record) => __('days.' . $record->name))
CheckboxList::make('days')
->label('Standaard beschikbaarheid')
->relationship('days', 'name', function (Builder $query) {
return $query->orderBy('day_of_week');
})
->getOptionLabelFromRecordUsing(fn (Model $record) => __('days.' . $record->name))
but it's not being sorted, does anyone know why?
10 replies
FFilament
Created by DanielvdSpoel on 10/17/2023 in #❓┊help
Filament testing breaks down as soon as i use a policy
So let's say i have a simple test:
it('can delete', function () {
$dataset = Dataset::factory()->create();

livewire(DatasetResource\Pages\EditDataset::class, [
'record' => $dataset->getRouteKey(),
])
->callAction(DeleteAction::class);

$this->assertModelMissing($dataset);
});
it('can delete', function () {
$dataset = Dataset::factory()->create();

livewire(DatasetResource\Pages\EditDataset::class, [
'record' => $dataset->getRouteKey(),
])
->callAction(DeleteAction::class);

$this->assertModelMissing($dataset);
});
THis works fine if there is no dataset policy, as soon as there is one i get this error: FAILED Tests\Feature\DatasetTest > it can delete Error
Call to a member function getAction() on null at vendor/filament/actions/src/Testing/TestsActions.php:141 137▕ / @var array<string> $name */ 138▕ / @phpstan-ignore-next-line */ 139▕ $name = $this->parseNestedActionName($name); 140▕ ➜ 141▕ $action = $this->instance()->getAction($name); 142▕ 143▕ $livewireClass = $this->instance()::class; 144▕ $prettyName = implode(' > ', $name); 145▕ +9 vendor frames 10 tests/Feature/DatasetTest.php:84 The policy returns true for all functions.. does anybody have a clue what's going on?
19 replies
FFilament
Created by DanielvdSpoel on 10/3/2023 in #❓┊help
CSS issue?
This is a pretty fresh project, but i have some weird css issue. I didn't publish any views and i did build my theme: https://gyazo.com/bcf5a7dbf4291588c06700fbed08599b
4 replies
FFilament
Created by DanielvdSpoel on 9/23/2023 in #❓┊help
Simple resource "new tenancy user" tries to create record upon opening model
See description, i have a plain simple resource but as soon as i click on the "new model" button it gives an error becouse it tries to insert a record into the database without any data. How can i fix this?
2 replies