Level 122
Try this instead;
$init->update($request->except(['thumbnail']));
1 like
Today i'm install Image Intervention in my project, and when i'm uploading image, then return new name of image, the result steel "tmp" file in my database, not the file name. the problem from update function, and no problem in store function.
this is my code
TemplateController.php :
private function upload($data)
{
// init
$file = \Image::make($data);
// set custom unique name for image
$newName = 'images/template/'.time().'_'.md5($data->getClientOriginalName()).'.'.$data->getClientOriginalExtension();
$file->save(public_path($newName), 70);
return $newName
}
public function update(Request $request, $id)
{
$init = Template::find($id);
if(!empty($request->thumbnail)) {
if(!empty(public_path($init->thumbnail))) {
unlink(public_path($init->thumbnail));
}
$init->thumbnail = $this->upload($request->thumbnail);
}
$init->update($request->all(), ['except'=>'thumbnail']);
$init->save();
\Session::flash('flash_message', [
'status' => 'success',
'message' => 'Sukses mengubah '.$init->title
]);
return redirect()->route('template.index');
}
after update, in database the update like this:
Try this instead;
$init->update($request->except(['thumbnail']));
Please or to participate in this conversation.