return $this->hasMany('City', 'district.CityID', 'city.CityID'); //this fails
not sure if that would work, i use laravel's innate db structure so i wont have any issue like this
lightshire said:
- Please follow laravel's innate db structure
return $this->hasMany('City', 'district.CityID', 'city.CityID'); //this fails
not sure if that would work, i use laravel's innate db structure so i wont have any issue like this
Thank you for your reply, but it does not work. I have no clue why Country->District works, but District->City ... I already spent few days on it... and totally clueless.
Fix that relationship with DistrictID
instead of CityID
and it will work, no need to prefix table name, Eloquent will do that for you on this relation query.
jarektkaczyk said:
Fix that relationship with
DistrictID
instead ofCityID
and it will work, no need to prefix table name, Eloquent will do that for you on this relation query.
OMG - I feel so stupid now... I can't believe it - I spent few days on it... reloaded my database few times, added and dropped keys in database, and did all kinds of troubleshooting. In the end, I just tried to link to not existing Column - LOL.
Thank you very, very much jarektkaczyk!!!
LOL - in the end I just tried to link Mode
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community