Level 102
You arent saving anything
$image = null; //remove this
$category->image = null;
$category->save();
//or
$category->update(['image' => null']);
1 like
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
How to clear a field in mysql with php?
public function delete(Category $category)
{
$image = $category->image;
if (!empty($image)) {
Storage::disk('public')->delete($image);
$image = null;
}
return redirect()->route('categories.index');
}
Why null is not working?
You arent saving anything
$image = null; //remove this
$category->image = null;
$category->save();
//or
$category->update(['image' => null']);
Please or to participate in this conversation.