FilamentF
Filament11mo ago
HGalih

Select with relationship inside repeater return null.

This must be something really stupid. But I've triple check all the relationship naming.

TradingPostResource.php
 Forms\Components\Repeater::make('trading_post_periodes')
                    ->columnSpanFull()
                    ->schema([
                        Select::make('periode_id')
                            ->required()
                            ->relationship('periode', 'periode_name'),
                        Forms\Components\TextInput::make('capacity')
                            ->required()
                            ->numeric()
                            ->default(25),
                    ]),
            ]);


TradingPostPeriode.php
    public function periode()
    {
        return $this->belongsTo(Periode::class);
    }


Error
Filament\Support\Services\RelationshipJoiner::prepareQueryForNoConstraints(): Argument #1 ($relationship) must be of type Illuminate\Database\Eloquent\Relations\Relation, null given, called in C:\Users\hanin\OneDrive\Documents\Eternity9\vendor\filament\forms\src\Components\Select.
Solution
Okay, I forgot to define the relationship on repeater. It's been a while since I touch filament. I thought filament pick up the relationship immidiately from repeater column name
Was this page helpful?