Voyager: id is ambigious

Created on 1 Jul 2017  路  6Comments  路  Source: the-control-group/voyager

  • Laravel Version: #.#.#
  • Voyager Version: last verisn
  • PHP Version:
  • Database Driver & Version: mysql

Description:

when i use the many to many relation it returns with an mysql error that id is ambigious
is that a bug ?

Steps To Reproduce:

public function voyagertags()
{
    return $this->belongsToMany('App\Tag','course_tag','course_id','tag_id')->withTimestamps();
}

have this is course model with courses table having voyagertags inside its columns

I have set the courses table bread to add this as a select multiple with relation key : id and when I want to see the page of courses bread inside admin panel i get this error back

SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'id' in field list is ambiguous (SQL: select `id`, `tag_name`, `course_tag`.`course_id` as `pivot_course_id`, `course_tag`.`tag_id` as `pivot_tag_id`, `course_tag`.`created_at` as `pivot_created_at`, `course_tag`.`updated_at` as `pivot_updated_at` from `tags` inner join `course_tag` on `tags`.`id` = `course_tag`.`tag_id` where `course_tag`.`course_id` in (3))

tags table has id as primary key and courses table has it too even course_tag has this primary key

@marktopper

invalid

Most helpful comment

@marktopper problem is solved
the problem was with the column id in pivot table
i guess it is a bug although buy any way if you remove it and make a key with the other 2 columns the problem will be solved

All 6 comments

Please enter the Step To Reproduce and ping me to reopen the issue.

@marktopper
updated thanks :-)

@marktopper problem is solved
the problem was with the column id in pivot table
i guess it is a bug although buy any way if you remove it and make a key with the other 2 columns the problem will be solved

Okay, I see the problem, however thanks for letting me know that it was solved 馃憤

I have the same problem, I removed the id column since in a pivot table this column makes no sense. But it would be nice to generate better join sql.

This issue has been automatically locked since there has not been any recent activity after it was closed. If you have further questions please ask in our Slack group.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Nagendra1421 picture Nagendra1421  路  3Comments

duongsieu picture duongsieu  路  3Comments

IvanBohonosiuk picture IvanBohonosiuk  路  4Comments

kevinjon27 picture kevinjon27  路  3Comments

craigb88 picture craigb88  路  3Comments