Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Post.php #187

Merged
merged 1 commit into from
Feb 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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