Laravel-medialibrary: VueJS integration?

Created on 3 Apr 2017  路  2Comments  路  Source: spatie/laravel-medialibrary

Hi there guys,

I love packages by Spattie because they are simple and yet powerful. I was wondering if there is a vueJS integration of the package.

Regards
Osvaldo Manuel

Most helpful comment

The package does not provide a vue.js integration, it's a bit out of scope for this package.

All 2 comments

How does php package must be integrated with vuejs? :)
You just need use vue.js resource package and send your files to your API and save it with this package.
Example:

filesChange: function (event) {
                if (!event.target.files.length) return;

                this.currentStatus = STATUS_SAVING;

                const formData = new FormData();

                if (this.options) {
                    _.each(this.options, function (value, key) {
                        formData.append(key, value);
                    });
                }

                let fileList = event.target.files;
                let fieldName = event.target.name;

                _.each(fileList, function (file, key) {
                    formData.append(fieldName, file);
                });

                this.$http.post(this.url, formData).then((response) => {
                    this.$emit('dropzoneUpdate', response.data.data);
                    this.currentStatus = STATUS_SUCCESS;
                }, (response) => {
                    toastr.error(response.statusText);
                    this.currentStatus = STATUS_FAILED;
                });

                event.target.form.reset();
            },

And here a medialibrary usage in the api side:

public function saveMedia(array $media)
    {
        foreach ($media as $item) {
            $this->model->addMedia($item)->toMediaCollection(SocialNetworkPost::MEDIA_COLLECTION);
        }

        return $this->model;
    }

Where in $media array we have a files which got with the Request class.

The package does not provide a vue.js integration, it's a bit out of scope for this package.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

aaronfullerton picture aaronfullerton  路  4Comments

snapey picture snapey  路  3Comments

ideadx picture ideadx  路  4Comments

stayallive picture stayallive  路  4Comments

kickthemooon picture kickthemooon  路  4Comments