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
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.
Most helpful comment
The package does not provide a vue.js integration, it's a bit out of scope for this package.