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

steveiest's avatar

Self-referential HasOne Relationship Nova Query

I have a Person (People) Laravel model, and two of the fields for that model are 'mother' and 'father'. Both of these relate to other People (i.e. the same model). I've got this working fine in Eloquent, but I'm struggling with Nova. I've set up the Model as follows:

public function father(): HasOne
{
    return $this->hasOne(Person::class, 'father');
}

The column in the migration:

$table->foreignId('father')->nullable()->constrained('people');

And the Nova Resource as follows:

HasOne::make('Father', 'father', \App\Nova\Person::class)->nullable(),

When I try to add a Resource, I don't get any errors, Nova just hangs and then times out. I'm at a bit of a loss as to what I've done wrong... any tips/advice at all?

Thank you.

0 likes
0 replies

Please or to participate in this conversation.