Closed hasnatbabur closed 4 years ago
It's possible with a pivot model and a table alias:
class Tag extends Model
{
use \Staudenmeir\EloquentHasManyDeep\HasRelationships;
public function tags()
{
return $this->hasManyDeep(
Tag::class,
[TagTagGroup::class, TagGroup::class, TagTagGroup::class.' as alias']
);
}
}
class TagTagGroup extends \Illuminate\Database\Eloquent\Relations\Pivot
{
use \Staudenmeir\EloquentHasManyDeep\HasTableAlias;
}
@staudenmeir It worked like a charm. Thanks a lot for the awesome essential library and quick support. You must deserve "World Class Top" developer crown. God bless you.
Can anyone help how can I get all related Tags for a Tag which can have multiple attached TagGroups? Thanks