Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

shahr's avatar
Level 10

How to clear a field in mysql with php?

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?

0 likes
1 reply
Sinnbeck's avatar
Sinnbeck
Best Answer
Level 102

You arent saving anything

$image = null; //remove this
$category->image = null;
$category->save();

//or
$category->update(['image' => null']);
1 like

Please or to participate in this conversation.