daljo25
error when loading data from a relationship in a select element
I want to load the names of the volunteer table in a select of the beneficiary resource but it gives me the following error
Filament\Support\Services\RelationshipJoiner::prepareQueryForNoConstraints(): Argument #1 ($relationship) must be of type Illuminate\Database\Eloquent\Relations\Relation, null given, called in C:\Users\daljo\dev\Caritas\vendor\filament\forms\src\Components\Select.php on line 773
code of resource
Forms\Components\Select::make('Volunteers_id')
->required()
->relationship('Volunteers', 'name')
->searchable()
->preload(),
model beneficiaries
public function volunteer(): BelongsTo
{
return $this->belongsTo(Volunteers::class);
}
model volunteers
public function beneficiaries() : HasMany
{
return $this->hasMany(Beneficiaries::class);
}
In advance, sorry for my bad English and if it is not well written, the post is my first time.2 replies