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

Relational fields#45

Draft
Larsklopstra wants to merge 15 commits into
masterfrom
relational-fields
Draft

Relational fields#45
Larsklopstra wants to merge 15 commits into
masterfrom
relational-fields

Conversation

@Larsklopstra
Copy link
Copy Markdown
Contributor

closes #10


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

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

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
Copy Markdown
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
Copy Markdown
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

Comment thread resources/views/resources/index.blade.php Outdated
Comment thread src/Contracts/NebulaField.php Outdated
Comment thread src/Fields/BelongsTo.php

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

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
Copy Markdown
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
Copy Markdown

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.

Comment thread src/Fields/BelongsTo.php Outdated
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