我想从用户那里获取图像然后重命名它,然后我想将重命名的图像名称保存到数据库中。这是我的控制器代码。我正在使用干预包。重命名后我可以将照片正确保存到目标文件夹,但重命名后我无法将照片的名称保存到我的数据库中。代码是什么?
public function store(UserRequest $request)
{
$farmer = User::create([
'name' => $request->name,
'phone' => $request->phone,
'address' => $request->address,
'nid' => $request->nid,
'dob' => $request->dob,
'remarks' => $request->remarks,
'division_id' => $request->division_id,
'district_id' => $request->district_id,
'upazila_id' => $request->upazila_id,
'farmer_point_id' => $request->farmer_point_id,
'user_type_id' => 3 // 3 is for farmer
]);
$image = Image::make($request->profile_picture);
$image->resize(250, 272);
$image->save(public_path("uploads/Farmers/farmer_$farmer->id.jpg"));
return redirect("farmer/{$farmer->id}");
}