I have two databases ("internal" and "external") and I would like to create a BelongsToMany relation between them. The problem, how do I specify in which database the relation_table is stored?
In my current case, I have some users that I would like to connect to some objects from an external database.
User:
public function objects() {
return $this->belongsToMany('\App\Object', 'user_object_relation');
}
Object:
protected $connection = 'mysql_data';
protected $table = 'objects';
protected $primaryKey = 'ObjectID';
Eloquent now is assuming my user_object_relation table in the mysql_data
(external) database, however I've created this in the "internal" database.
Q: How do I tell eloquent that the relation table is not in the external table?
// edit:
with return $this->belongsToMany('\App\Object', 'internal.user_object_relation');
, I receive an access denied error because the "external" database user has no access to the internal ;)