Closed webazinsupp closed 4 years ago
I'll consider it.
In the meantime, you can use the HasOneDeep
relationship from the other package:
class Product extends Model
{
use \Staudenmeir\EloquentHasManyDeep\HasRelationships;
public function parentCategory()
{
return $this->hasOneDeep(
Category::class,
[Category::class.' as alias'],
['id', 'id'],
['category_id', 'category_id']
);
}
}
class Category extends Model
{
use \Staudenmeir\EloquentHasManyDeep\HasTableAlias;
}
very very good, tnx for help this work for me
I've released a new version that adds support for table aliases (requires Laravel 6+):
class Product extends Model
{
use \Znck\Eloquent\Traits\BelongsToThrough;
public function parentCategory()
{
return $this->belongsToThrough(Category::class, [Category::class.' as alias']);
}
}
class Category extends Model
{
use \Znck\Eloquent\Traits\HasTableAlias;
}
hi a'm use this package and try get sub category of product same below: Category → Has many → Category → Has many → Product
in category model
and get parent category of product same this in product model:
but this error:
in staudenmeir/eloquent-has-many-deep package use Table Aliases trait but in this package not use, please set this trait in this package