What seems to be the problem:
After watching the video (https://laravel-livewire.com/screencasts/s5-integrating-with-filepond) I put two components of file-pond in the same page each with different model and I made one with multiple attribute and the other without.
The models are: $coverPhoto, and $gallery
The problem: when I prepare a file to upload in $coverPhoto and I put a dd($coverPhoto)
in the component php file I get null and when I put another one with the other model dd($gallery)
I get file info even I didn’t select files to upload in the $gallery
component
Are you using the latest version of Livewire: Yes
Do you have any screenshots or code examples:
Below is the code of Form livewire
component
public $coverPhoto = null;
public $gallery = [];
protected $rules = [
'coverPhoto' => 'nullable|image|max:2048',
'gallery.*' => 'nullable|image|max:2048',
];
public function saveProfile()
{
if ($this->coverPhoto) {
$cover = $this->coverPhoto->store('/', 'gallery');
auth()->user()->profile()->update([
'cover_photo' => $cover
]);
}
if($this->gallery){
foreach ($this->gallery as $key => $photo){
$this->gallery[$key] = $photo->store('/' .
str_replace(' ', '', auth()->user()->name) . auth()->user()->id,
'gallery');
}
$this->gallery = json_encode($this->gallery);
auth()->user()->profile()->update([
'gallery' => $this->gallery
]);
}
}
The view for the two components: