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:
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'); }...
Jump to solution
5 Replies
codeartisan
codeartisanOP14mo ago
No description
Dennis Koch
Dennis Koch14mo ago
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.
codeartisan
codeartisanOP14mo ago
That means I should double check my relationships on the models
Dennis Koch
Dennis Koch14mo ago
Yep. Why do you want to use the district code instead of the ID as the foreign key at all?
Solution
codeartisan
codeartisan14mo ago
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'); }
Want results from more Discord servers?
Add your server