I have an edit form with a text field and an image field where a user can edit and upload new text or a image if he/she wants to. But if the user does not upload a new image I just want to keep the old image in the database.

**My Problem**

The problem is when I hit upload button, I'm redirected to the article page and no error is shown but the DB has not been updated what so ever.

Any help would be appreciated as I have tried multiple methods with no success.

Thank you in advance.

web.php

```
Route::get('/tests/edit/{id}', 'TestController@edit');
Route::patch('/tests', 'TestController@update');

```

TestController.php

```
public function edit(Request $request)
{ 
    $test = Test::findOrFail($request->id);
    return view('test.edit', ['test' => $test]);
}

public function update(Request $request, Test $test)
{
    $test->user_id = $request->user()->id;
    $test->name = $request->name;

    if($request->hasFile('image')) {
        Storage::delete('public/image/' . $test->image); //Delete old image
        $path = $request->file('image')->store('public/image');
        $test->image = basename($path);
    }

    $test->update();

    return redirect('/tests')
}

```

edit.blade.php

```
@extends('layouts.app')

@section('content')
<div>
    <form action="/tests" method="post" enctype="multipart/form-data">
        {{ csrf_field() }}
        {{ method_field('patch') }}
            name：<input type="text" name="name" value='{{ $test->name }}'><br>
            image： <input type="file" name="image"><br>
            <input type='submit' value='upload'>
    </form>
</div>
@endsection

```