You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello, i'm having trouble creating a new relationship that uses hasManyDeepFromRelations.
Error SQLSTATE[42000]: Syntax error or access violation: 1066 Not unique table/alias: 'users'
I've tried to use HasTableAlias on User Model and Blog Model but it didn't work as expected
Expected result
Merge 3 relationships (user,creator,commenters) into one (participants). What i'm doing wrong here?
Blog Model
public function user(): BelongsTo
{
return $this->belongsTo(User::class);
}
public function creator(): BelongsTo
{
return $this->belongsTo(User::class);
}
public function commenters(): BelongsToMany
{
return $this->belongsToMany(User::class, BlogComment::class)->distinct();
}
/**
* Get participants.
*
* @todo: We should get the users who comments + creator + user
*
* @return HasManyDeep
*/
public function participants(): HasManyDeep
{
return $this->hasManyDeepFromRelations($this->commenters(), $this->user(), $this->creator());
}
The text was updated successfully, but these errors were encountered:
This is actually a misunderstanding of the package's purpose: It allows you to concatenate/chain relationships (A -> B -> C -> D) but not to merge them – that's a different (and more complicated) topic. I also created a package for this: https://github.com/staudenmeir/laravel-merged-relations
Hello, my bad, i thought it would fit my needs. I've tried your solution and it almost worked, i created a new issue on your laravel-merged-relations: staudenmeir/laravel-merged-relations#6
Hello, i'm having trouble creating a new relationship that uses
hasManyDeepFromRelations
.Error
SQLSTATE[42000]: Syntax error or access violation: 1066 Not unique table/alias: 'users'
I've tried to use
HasTableAlias
onUser Model
andBlog Model
but it didn't work as expectedExpected result
Merge 3 relationships (user,creator,commenters) into one (participants). What i'm doing wrong here?
Blog Model
The text was updated successfully, but these errors were encountered: