Relationship manager using a wrong identifier
II have created a relationship manager it displays the results when I navigate to the view page but the output is not right
This is how I created the relationship manager
php artisan make:filament-relation-manager DistrictResource counties districtCode so I thought it has use the districtCode as the foreign key but instead its not using it
Solution:Jump to solution
solved i had missed passing the local key in the model so it would reference the id but now it works fine thank you
public function counties():HasMany
{
return $this->hasMany(County::class, 'districtCode', 'districtCode');
}...
5 Replies
Please don’t double post. Bump the existing post.
The relation manager is using the underlying relation. It doesn’t handle the records that are loaded.
That means I should double check my relationships on the models
Yep.
Why do you want to use the district code instead of the ID as the foreign key at all?
Solution
solved i had missed passing the local key in the model so it would reference the id but now it works fine thank you
public function counties():HasMany
{
return $this->hasMany(County::class, 'districtCode', 'districtCode');
}