laravel-couchdb
laravel-couchdb copied to clipboard
Failure on selecting field in a belongsToMany relationship
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.