FilamentF
Filament3y ago
N1XN

Access nested sum

How can I display the dose_count inside a TextColumn?

    public static function getEloquentQuery(): Builder
    {
        return parent::getEloquentQuery()->with(['patients' => function ($query) {
            $query->withSum('latestPatientProtocol', 'dose_count');
        }]);
    }
Solution
I am not sure, because I solved this - but I think this way I would loose sorting, or would have to implement it manually.

I fixed it by defining the needed relationship inside the model, so I don't have to traverse.

https://github.com/staudenmeir/eloquent-has-many-deep
GitHub
Laravel Eloquent HasManyThrough relationships with unlimited levels - GitHub - staudenmeir/eloquent-has-many-deep: Laravel Eloquent HasManyThrough relationships with unlimited levels
Was this page helpful?