Skip to content
This repository has been archived by the owner on Oct 2, 2021. It is now read-only.

Failure on selecting field in a belongsToMany relationship #20

Open
robsonvn opened this issue May 25, 2018 · 0 comments
Open

Failure on selecting field in a belongsToMany relationship #20

robsonvn opened this issue May 25, 2018 · 0 comments

Comments

@robsonvn
Copy link
Owner

Code example:

  public function users(){
    return $this->belongsToMany('App\User')->select(['first_name']);
  }

Error message:

``
(1/1) ErrorExceptionInvalid argument supplied for foreach()

in BelongsToMany.php line 264
``

Probable cause:

When the user specifies the columns it's ignoring the foreign key column "company_ids" which impacts the crossmatch between users and companies.

Suggest solution

Force foreign key to be selected as _id and _rev.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant