阿尔及利亚变形模型的热负荷关系

时间:2020-09-21 08:19:26

标签: laravel algolia laravel-scout s

我正在使用扩展的侦察器,因为我在一个索引中有多个模型(我正在使用聚合器)

聚合器是

class AllPosts extends Aggregator
{
    /**
     * The names of the models that should be aggregated.
     *
     * @var string[]
     */
    protected $models = [
        'App\Thread',
        'App\Reply',
        'App\ProfilePost',
    ];



    protected $relations = [
        ProfilePost::class => ['poster', 'profileOwner'],
        Thread::class => ['poster', 'category'],
        Reply::class => [
            'poster',
            'repliable.category',
            'repliable.profileOwner',
        ],
    ];

答复是一个模型模型,具有可复制关系,该关系可以是主题个人资料发布 >。

对于 ProfilePost ,我还需要同时加载 profileOwner

对于线程,我还需要加载类别

不幸的是,这无法完成,因为当我有一个带有可复制的线程回复时,它会尝试加载仅存在的 profileOwner 个人资料发布

我找不到使用 morphWith 的方法。

例如在laravel中我们可以做到

->with(['model_name' => function ($morphTo) {
                $morphTo->morphWith([
                    Thread::class => ['poster', 'category'],
                    ProfilePost::class => ['poster', 'profileOwner]

还有使用algolia实现这一目标的替代方法吗?

0 个答案:

没有答案