2 months ago

hasOneThrough RelationShip

Posted 2 months ago by ethar

i have City Model (id,name),


Address Model (id,cities_id,users_id)


Orders Model (id,products_id,addresses_id).

in Orders Model i wrote this function to get city Name

    public function cities(){
        return $this->hasOneThrough(

but i got this error

SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'id' in field list is ambiguous (SQL: select `id`, `city_name_ar`, `price`, `addresses`.`cities_id` as `laravel_through_key` from `cities` inner join `addresses` on `addresses`.`id` = `cities`.`addresses_id` where `addresses`.`cities_id` in (1, 2, 3, 4))

Please sign in or create an account to participate in this conversation.