Skip to content
Discussion options

You must be logged in to vote

Hi @vdeep!

In order to achieve this, you should use a "MorphOne (1-1 polymorphic) + subfields" field.
You have an example in our demo 👌

Basically, you should setup your attachment relationship field with subfields, and one of those subfields (in your case the only one) should be your filename which is an upload field type.

Backpack will handle the rest for you 👌

CRUD::addField([
    'name' => 'attachment',
    'label' => 'Attachment',
    'subfields' => [
        [
            'name' => 'filename',
            'type' => 'upload',
            'withFiles' => [
                'disk' => 'public',
                'path' => 'uploads',
            ],
        ],
		// more fields may go here...

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@vdeep
Comment options

Answer selected by pxpm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants