I was trying to setup a BelongsToMany relationship where one of the columns is not an ID reference, but rather a string reference.
return $this->belongsToMany('User', 'chats_users', 'chat_id', 'user_email');
Is it possible to do this?
I was trying to setup a BelongsToMany relationship where one of the columns is not an ID reference, but rather a string reference.
return $this->belongsToMany('User', 'chats_users', 'chat_id', 'user_email');
Is it possible to do this?
This should work as long as the string reference is a primary key of the parent table although it's not recommended. Be sure to check this explanation on using strings as primary keys
return $this->belongsToMany('User', 'chats_users', 'chat_id', 'user_email');