Use associative array instead with the name in it instead of $serviceDetails
$data = $request->only(['your', 'properties', 'without', 'image_name']);
$data['image_name'] = $imageName;
$services = $this->serviceRepository->createService($data);
I am trying to save an image into the public folder with the company name in a form.
I have this in my controller
public function store(ServiceRequest $request)
{
$imageName = time().'.'.$request->logo_light->extension();
$request->logo_light->move(public_path('services'), $imageName);
//Validate all request
$serviceDetails = $request->validated();
$services = $this->serviceRepository->createService($serviceDetails);
return redirect('/system-integrators');
}
Although this code saves inside the public folder but in the database it saves as C:\wamp\tmp\php933.tmp
I want it to save like this companyname.jpg
@monstajamss That should work.
$imageName = $request->company_name.'.'.$request->logo_light->extension();
use dd with $data before you save and see its values.
Please or to participate in this conversation.