-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Closed
Labels
Description
My code (not relevant parts omitted):
class User extends Authenticatable
{
use Notifiable;
use HybridRelations;
protected $connection = 'mysql';
public function messages()
{
return $this->belongsToMany(Message::class);
}
}
use Jenssegers\Mongodb\Eloquent\Model as Eloquent;
use App\Models\User;
class Message extends Eloquent
{
protected $connection = 'mongodb';
protected $collection = 'messages';
public function users()
{
return $this->belongsToMany(User::class);
}
}
Now:
Message::first()->users()->attach( User::first() ); //Stores in the pivot table in MySQL
User::first()->messages()->attach( Message::first() ); //Stores in the embedded relation in MongoDB
The issue now is that I'm only able to retrieve the users from a message (if I used the first method) OR viceversa.
Is it possible to specify the connection on which the relation is stored?
So I would be able to update and read both object from both the relations.
andresgcarmona and deki23