© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago•
2 replies
N1XN

RelationManager attempts to lazy load relations

I have created an Attribute to display a range, which combines
min
min
and
max
max
BelongsTo Relations, but I get the enabled
strictMode
strictMode
error thrown.

Attempted to lazy load [minDose] on model [App\Models\PatientMedication] but lazy loading is disabled.
Attempted to lazy load [minDose] on model [App\Models\PatientMedication] but lazy loading is disabled.


Is there a way how I can manually load the needed relations via
TextColumn
TextColumn
API?

// MedicationDoseRelationManager
// ...
TextColumn::make('medicationDoseRange')
    ->label('Dose'),
// ...
// MedicationDoseRelationManager
// ...
TextColumn::make('medicationDoseRange')
    ->label('Dose'),
// ...


class PatientMedication extends Model
{
    public function minDose(): BelongsTo
    {
        return $this->belongsTo(Dose::class, 'min_dose_id');
    }

    public function maxDose(): BelongsTo
    {
        return $this->belongsTo(Dose::class, 'max_dose_id');
    }

    protected function medicationDoseRange(): Attribute
    {
        return Attribute::make(
            get: function () {
                $consolidatedValue = $this->minDose->name === $this->maxDose->name; // Error get trown

                return $consolidatedValue
                    ? $this->minDose->name
                    : $this->minDose->name.' - '.$this->maxDose->name;
            }
        );
    }
}
class PatientMedication extends Model
{
    public function minDose(): BelongsTo
    {
        return $this->belongsTo(Dose::class, 'min_dose_id');
    }

    public function maxDose(): BelongsTo
    {
        return $this->belongsTo(Dose::class, 'max_dose_id');
    }

    protected function medicationDoseRange(): Attribute
    {
        return Attribute::make(
            get: function () {
                $consolidatedValue = $this->minDose->name === $this->maxDose->name; // Error get trown

                return $consolidatedValue
                    ? $this->minDose->name
                    : $this->minDose->name.' - '.$this->maxDose->name;
            }
        );
    }
}
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Relationmanager update rooted relations
FilamentFFilament / ❓┊help
2y ago
RelationManager with lazy loading disabled
FilamentFFilament / ❓┊help
2y ago
Lazy load tab
FilamentFFilament / ❓┊help
15mo ago
Lazy load table column
FilamentFFilament / ❓┊help
16mo ago