@anonymouse703 I don't think saving the image itself on the database is a good idea.
Looks like you are on the right track, just save the file into a folder and save the filename into the DB so you can reference it later when needed.
Hi guys I have to image to upload (profile and sketch), What is the best way to upload it in database?
So far, this is what I did but it's definitely missing some code.
public function store(){
$action = '';
$data = $this->validate([
'gender' => 'required',
'profile' => 'image|max:1024',
'last_name' => 'required',
'first_name' => 'required',
'middle_name' => 'required',
'street' => 'required',
'barangay' => 'required',
'city' => 'required',
'province' => 'required',
'sketch' => 'image|max:1024',
'birth_date' => 'required | date',
'gender_id' => 'required',
'civil_status_id' => 'required',
'spouse' => 'required',
'tel_no' => 'required',
'cell_no1' => 'required | integer',
'cell_no2' => 'required | integer',
'employer' => 'required',
'employer_address' => 'required',
'employer_contact' => 'required'
]);
$this->profile->storage('images','public');
$this->sketch->storage('images','public');
if($this->customerId){
Customer::find($this->customerId)->update($data);
$action = 'edit';
}else{
Customer::create($data);
$action = 'store';
}
$this->emit('showEmitedFlashMessage', $action);
$this->resetInputFields();
$this->emit('refreshParent');
$this->emit('closeCustomerModal');
}
Please or to participate in this conversation.