Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Mutator don't triggered with extra pivot when save file in subfield #4874

Closed
Matthieu24 opened this issue Jan 3, 2023 · 2 comments
Closed
Labels

Comments

@Matthieu24
Copy link

Bug report

Hi,

I tried to save files in the pivot table, but when I saved, I got this output in the database: [{}].
My setDiplomaDocumentAttribute() function does not seem to be used.

What I did

CRUD :

 'subfields' => [ 
                            [
                                'name'      => 'diploma_document',
                                'label'     => 'Fichiers',
                                'type'      => 'upload_multiple',
                                'upload'    => true,
                                'wrapper' => [
                                    'class' => 'form-group col-md-9',
                                ],
                            ],
                        ],

Model:

public function diplomas()
    {
        return $this->belongsToMany(Diploma::class, 'user_diploma','user_id','diploma_id')->withPivot('diploma_document');
    }   
    
public function setDiplomaDocumentAttribute($value)
    {
        $attribute_name = "diploma_document";
        $disk = "local";
        $destination_path = "diploma_documents";

        $this->uploadMultipleDiplomasToDisk($value, $attribute_name, $disk, $destination_path);
    }

What I expected to happen

Files are saved

What happened

Files is not saved and the value [{}] appears in the database.

What I've already tried to fix it

I tried to call the function in CRUD but I get a [null] value in the database.

'subfields' => [ 
                            [
                                'name'      => 'diploma_document',
                                'label'     => 'Fichiers',
                                'type'      => 'upload_multiple',
                                'upload'    => true,
                                'function'  => function($entry){
                                    $entry->setDiplomaDocumentAttribute();
                                },
                                'wrapper' => [
                                    'class' => 'form-group col-md-9',
                                ],
                            ],
                        ],

Backpack, Laravel, PHP, DB version

PHP VERSION:

PHP 8.1.3 (cli) (built: Feb 16 2022 08:20:53) (NTS Visual C++ 2019 x64)
Copyright (c) The PHP Group
Zend Engine v4.1.3, Copyright (c) Zend Technologies

LARAVEL VERSION:

v9.45.1@faeb20d3fc61b69790068161ab42bcf2d5faccbc

BACKPACK VERSION:

5.4.11@ffbadcdb6478822646600b2cd763490caa927155

@welcome
Copy link

welcome bot commented Jan 3, 2023

Hello there! Thanks for opening your first issue on this repo!

Just a heads-up: Here at Backpack we use Github Issues only for tracking bugs. Talk about new features is also acceptable. This helps a lot in keeping our focus on improving Backpack. If you issue is not a bug/feature, please help us out by closing the issue yourself and posting in the appropriate medium (see below). If you're not sure where it fits, it's ok, a community member will probably reply to help you with that.

Backpack communication channels:

  • Bug Reports, Feature Requests - Github Issues (here);
  • Quick help (How do I do X) - Gitter Chatroom;
  • Long questions (I have done X and Y and it won't do Z wtf) - Stackoverflow, using the backpack-for-laravel tag;
  • Showing off something you've made, asking for opinion on Backpack/Laravel matters - Reddit;

Please keep in mind Backpack offers no official / paid support. Whatever help you receive here, on Gitter, Slack or Stackoverflow is thanks to our awesome awesome community members, who give up some of their time to help their peers. If you want to join our community, just start pitching in. We take pride in being a welcoming bunch.

Thank you!

--
Justin Case
The Backpack Robot

@Matthieu24
Copy link
Author

I just saw that it is the same problem as the repo #4676 and 4141 so I close

@Matthieu24 Matthieu24 closed this as not planned Won't fix, can't repro, duplicate, stale Jan 9, 2023
@github-project-automation github-project-automation bot moved this to Done in This week Jan 9, 2023
@tabacitu tabacitu removed this from This week Jun 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant