From 22167896c2554d846b599e88272ac3ec189b3e80 Mon Sep 17 00:00:00 2001 From: Bradley Miller Date: Fri, 16 Feb 2024 14:02:17 -0600 Subject: [PATCH] Update Post.php See comments on issue with the author() area --- src/Models/Post.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Models/Post.php b/src/Models/Post.php index d2ab738..41e5215 100644 --- a/src/Models/Post.php +++ b/src/Models/Post.php @@ -91,7 +91,11 @@ public function statusDesc(): string /** @return BelongsTo */ public function author(): BelongsTo { - return $this->belongsTo(config('auth.providers.users.model'), 'user_id', 'id'); + // return $this->belongsTo(config('auth.providers.users.model'), 'user_id', 'id'); + // To acocomodate using LDAPRecord ( https://ldaprecord.com/docs/laravel/v3/auth/database/configuration#introduction ) the belongs to relation needs to look back at the database model rather than the LDAP model. The LDAP model itself doesn't have provision for + // the belongsTo relationship and instead gives an error from the Spatie permissions side: LDAP RECORD with Spatie Permissions gives error "The LDAP connection [mysql] does not exist." + return $this->belongsTo( !empty(config('auth.providers.users.database.model')) ? config('auth.providers.users.database.model') : config('auth.providers.users.model'), 'user_id', 'id'); + } /** @return BelongsTo */