Skip to content
This repository has been archived by the owner on Nov 23, 2021. It is now read-only.

Relational fields #45

Draft
wants to merge 15 commits into
base: master
Choose a base branch
from
Draft

Relational fields #45

wants to merge 15 commits into from

Conversation

Larsklopstra
Copy link
Contributor

closes #10


<x-nebula::form-row :field="$field">

<p class="text-sm">{{ $field->resolveBelongsTo($item) }}</p>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One idea might be making this a link to the related resource, if it exists as a resource in Nebula.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is done via the BelongsTo field, eg: BelongsTo::make('Users', 'user_id')->resource(UserResource::class);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could also implement an auto resolver like other classes do, but this will work for now


class BelongsTo extends NebulaField
{
use HasHelperText, HasResource;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like all NebulaField instances should have access to the resource, so perhaps it makes more sense to add the trait to the parent class instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe a naming issue, but this is a BelongsTo resource, so a PostResource is able to resolve the UserResource, explained it earlier a little^

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, perhaps it's a naming issue then.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Relationships fields
2 participants