Skip to content
Advertisement

Laravel Nova Self-referential Relationship

In Laravel, if I want to create a self-referential relationship I can do the following:

JavaScript

How can I make a Laravel Nova resource display this connection?

JavaScript

Advertisement

Answer

You can achieve what you want like this:

JavaScript

This will allow to choose a parent post when you create or update a post. When you are in the detail page of a post, you can see all its children.

JavaScript

Note: Please note that the third param to BelongsTo::make() and HasMany::make() is a reference to the Post Resource, not Post model.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement