From 4677de9c05707439e2c1c11e3bae5d4fbb8bc359 Mon Sep 17 00:00:00 2001 From: FredPeal Date: Wed, 14 Feb 2024 13:53:04 -0400 Subject: [PATCH 1/3] fix: connection database many to many channel --- src/Domains/Social/Channels/Models/Channel.php | 4 ++-- .../Social/Channels/Repositories/ChannelRepository.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Domains/Social/Channels/Models/Channel.php b/src/Domains/Social/Channels/Models/Channel.php index b1a49be63..1fa5c1596 100644 --- a/src/Domains/Social/Channels/Models/Channel.php +++ b/src/Domains/Social/Channels/Models/Channel.php @@ -33,9 +33,9 @@ class Channel extends BaseModel public function users(): BelongsToMany { - $databaseSocial = config('database.social.database', 'social'); + $databaseSocial = config('database.connections,.social.database', 'social'); - return $this->belongsToMany(Users::class, $databaseSocial . '.channel_users', 'channel_id', 'users_id') + return $this->belongsToMany(Users::class, 'channel_users', 'channel_id', 'users_id') ->withTimestamps() ->withPivot('roles_id'); } diff --git a/src/Domains/Social/Channels/Repositories/ChannelRepository.php b/src/Domains/Social/Channels/Repositories/ChannelRepository.php index 409065c06..374293efb 100644 --- a/src/Domains/Social/Channels/Repositories/ChannelRepository.php +++ b/src/Domains/Social/Channels/Repositories/ChannelRepository.php @@ -17,7 +17,7 @@ public static function getById(int $id, Users $user): Channel public static function getByIdBuilder(Users $user): Builder { - $databaseSocial = config('database.social.database', 'social'); + $databaseSocial = config('database.connections,.social.database', 'social'); $builder = Channel::join($databaseSocial . '.channel_users', 'channel_users.channel_id', '=', 'channels.id') ->where('users_id', auth()->user()->id); From e3f7059e85ee843cc7c431a0f0a4e91ca019a52e Mon Sep 17 00:00:00 2001 From: FredPeal Date: Wed, 14 Feb 2024 14:00:24 -0400 Subject: [PATCH 2/3] fix: channel connection --- src/Domains/Social/Channels/Models/Channel.php | 2 +- src/Domains/Social/Channels/Repositories/ChannelRepository.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Domains/Social/Channels/Models/Channel.php b/src/Domains/Social/Channels/Models/Channel.php index 1fa5c1596..bf73adc36 100644 --- a/src/Domains/Social/Channels/Models/Channel.php +++ b/src/Domains/Social/Channels/Models/Channel.php @@ -33,7 +33,7 @@ class Channel extends BaseModel public function users(): BelongsToMany { - $databaseSocial = config('database.connections,.social.database', 'social'); + $databaseSocial = config('database.connections.social.database', 'social'); return $this->belongsToMany(Users::class, 'channel_users', 'channel_id', 'users_id') ->withTimestamps() diff --git a/src/Domains/Social/Channels/Repositories/ChannelRepository.php b/src/Domains/Social/Channels/Repositories/ChannelRepository.php index 374293efb..9b1ee3dd7 100644 --- a/src/Domains/Social/Channels/Repositories/ChannelRepository.php +++ b/src/Domains/Social/Channels/Repositories/ChannelRepository.php @@ -17,7 +17,7 @@ public static function getById(int $id, Users $user): Channel public static function getByIdBuilder(Users $user): Builder { - $databaseSocial = config('database.connections,.social.database', 'social'); + $databaseSocial = config('database.connections.social.database', 'social'); $builder = Channel::join($databaseSocial . '.channel_users', 'channel_users.channel_id', '=', 'channels.id') ->where('users_id', auth()->user()->id); From e4393a7a2629901a40828ed307156c5cd4789258 Mon Sep 17 00:00:00 2001 From: FredPeal Date: Wed, 14 Feb 2024 14:14:50 -0400 Subject: [PATCH 3/3] fix: database social in model channel --- src/Domains/Social/Channels/Models/Channel.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Domains/Social/Channels/Models/Channel.php b/src/Domains/Social/Channels/Models/Channel.php index bf73adc36..409755c88 100644 --- a/src/Domains/Social/Channels/Models/Channel.php +++ b/src/Domains/Social/Channels/Models/Channel.php @@ -35,7 +35,7 @@ public function users(): BelongsToMany { $databaseSocial = config('database.connections.social.database', 'social'); - return $this->belongsToMany(Users::class, 'channel_users', 'channel_id', 'users_id') + return $this->belongsToMany(Users::class, $databaseSocial . '.channel_users', 'channel_id', 'users_id') ->withTimestamps() ->withPivot('roles_id'); }