Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

skoobi's avatar
Level 13

Nova return relationship where Status == 1

Hi. I can't seem to find any solution that has worked yet. What I'm trying to get working is I have a "Step" resource and it has a belongsTo "Type". When its grabbing the data from type, I want it to only return where status is Active.

How to i go about this?

Cheers

0 likes
2 replies
nexxai's avatar

Please show your relationships and example code that isn't working

skoobi's avatar
Level 13

@nexxai Ah, sorry!

The Step Resource:

BelongsTo::make('Type', 'type', 'App\Nova\Type')
                    ->filterable()
                    ->sortable()
                    ->textAlign('left'),

The Step Model

public function type()
    {
        return $this->belongsTo(Type::class)
            ->where('status', 1)
            ->orderBy('title');
    }

Please or to participate in this conversation.