Upload Image on form to a Livewire component

I have a form that has fileupload and is uploading images. On the Filament Resource it all works fine but I also have a form on a custom livewire component on a custom page. All works fine except the file. It is saving the object instead of the path to the database. How can i extract the path here is the dump od $this->data
array:12 [▼ // app/Livewire/OrganisationProfile.php:118
"id" => 2
"name" => "NCCM"
"logo" => array:1 [▼
"2948ff41-e4ae-4094-82b0-f989ed85a318" => Livewire\Features\SupportFileUploads\TemporaryUploadedFile {#1135 ▼
-test: false
-originalName: "V5bm8BgjsJ2yDJMcL41q71GGZ1GEOM-metabmNtTG9nby5wbmc=-.png"
-mimeType: "application/octet-stream"
-error: 0
#hashName: null
#disk: "local"
#storage: Illuminate\Filesystem\FilesystemAdapter {#1119 ▶}
#path: "livewire-tmp/V5bm8BgjsJ2yDJMcL41q71GGZ1GEOM-metabmNtTG9nby5wbmc=-.png"
path: "/Users/jacques/repos/nccm/storage/app/livewire-tmp"
filename: "V5bm8BgjsJ2yDJMcL41q71GGZ1GEOM-metabmNtTG9nby5wbmc=-.png"
basename: "php0jI5V7"
pathname: "/private/var/tmp/php0jI5V7"
extension: ""
realPath: "/Users/jacques/repos/nccm/storage/app/livewire-tmp/V5bm8BgjsJ2yDJMcL41q71GGZ1GEOM-metabmNtTG9nby5wbmc=-.png"
aTime: 2023-10-21 01:13:02
mTime: 2023-10-21 01:13:02
cTime: 2023-10-21 01:13:02
inode: 18827423
size: 91313
writable: false
readable: false
executable: false
file: false
dir: false
link: false
}
]
"district" => "Springbok"
"contact_person" => "Ms. Pamela Witting"
"contact_number" => "(270) 772-6158"
"email" => "[email protected]"
"website" => "yundt.info/occaecati-magni-est-itaque-nobis-itaque-saepe-illum"
"councilors" => "0"
"votes" => "1000-1999"
"created_at" => "2023-10-19T17:51:00.000000Z"
"updated_at" => "2023-10-21T00:43:50.000000Z"
]
array:12 [▼ // app/Livewire/OrganisationProfile.php:118
"id" => 2
"name" => "NCCM"
"logo" => array:1 [▼
"2948ff41-e4ae-4094-82b0-f989ed85a318" => Livewire\Features\SupportFileUploads\TemporaryUploadedFile {#1135 ▼
-test: false
-originalName: "V5bm8BgjsJ2yDJMcL41q71GGZ1GEOM-metabmNtTG9nby5wbmc=-.png"
-mimeType: "application/octet-stream"
-error: 0
#hashName: null
#disk: "local"
#storage: Illuminate\Filesystem\FilesystemAdapter {#1119 ▶}
#path: "livewire-tmp/V5bm8BgjsJ2yDJMcL41q71GGZ1GEOM-metabmNtTG9nby5wbmc=-.png"
path: "/Users/jacques/repos/nccm/storage/app/livewire-tmp"
filename: "V5bm8BgjsJ2yDJMcL41q71GGZ1GEOM-metabmNtTG9nby5wbmc=-.png"
basename: "php0jI5V7"
pathname: "/private/var/tmp/php0jI5V7"
extension: ""
realPath: "/Users/jacques/repos/nccm/storage/app/livewire-tmp/V5bm8BgjsJ2yDJMcL41q71GGZ1GEOM-metabmNtTG9nby5wbmc=-.png"
aTime: 2023-10-21 01:13:02
mTime: 2023-10-21 01:13:02
cTime: 2023-10-21 01:13:02
inode: 18827423
size: 91313
writable: false
readable: false
executable: false
file: false
dir: false
link: false
}
]
"district" => "Springbok"
"contact_person" => "Ms. Pamela Witting"
"contact_number" => "(270) 772-6158"
"email" => "[email protected]"
"website" => "yundt.info/occaecati-magni-est-itaque-nobis-itaque-saepe-illum"
"councilors" => "0"
"votes" => "1000-1999"
"created_at" => "2023-10-19T17:51:00.000000Z"
"updated_at" => "2023-10-21T00:43:50.000000Z"
]
at moment its storing the object in database.
Solution:
Use
$data = $this->form->getState();
$this->organization->update($data);
$data = $this->form->getState();
$this->organization->update($data);
...
Jump to solution
6 Replies
Jacques
JacquesOP2y ago
Its the logo btw I am trying to save with $this->organisation->update($this->data);
Jacques
JacquesOP2y ago
No description
Solution
awcodes
awcodes2y ago
Use
$data = $this->form->getState();
$this->organization->update($data);
$data = $this->form->getState();
$this->organization->update($data);
The getState() will run the validations and persist the images and return what you need.
Jacques
JacquesOP2y ago
Thanks and thank you for explaining as well. It works
Jacques
JacquesOP2y ago
and I see now its in the docs 🥺
awcodes
awcodes2y ago
all good. happens to us all.

Did you find this page helpful?