Skip to content

Commit

Permalink
Update Post.php
Browse files Browse the repository at this point in the history
See comments on issue with the author() area
  • Loading branch information
HeartlandTechie authored Feb 16, 2024
1 parent d96269e commit 2216789
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Models/Post.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,11 @@ public function statusDesc(): string
/** @return BelongsTo<Post, Model> */
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<Post, Post> */
Expand Down

0 comments on commit 2216789

Please sign in to comment.