title: getting error when i update image in my admin panel
body: <p>I want to update my product table but when I update my product table, it throws this error : </p>
  
  <blockquote>
    <p>ErrorException in CreatesController.php line 201: Undefined variable:
    name</p>
  </blockquote>
  
  <pre><code>201 line is this: 'image'=&gt; $name,
  </code></pre>
  
  <p><strong>My product table contains following fields :</strong></p>
  
  <pre><code>productname,image,price,category_id
  </code></pre>
  
  <p><strong>This is CreatesController :</strong></p>
  
  <pre><code>public function productupdate(Request $request, $id){
  
  $this-&gt;validate($request, [
  
  'productname'=&gt;'required',
  
  'image'=&gt;'image|mimes:jpg,png,jpeg|max:10000',
  
  'price'=&gt;'required',
  
  'category_id'=&gt;'required'
  
  ]);
  
  if($request-&gt;hasfile('image'))
  
  {
  
    $file=$request-&gt;file('image');
  
    $new_name = rand(). '.' .
  
    $path=public_path().'/images';
  
    $name=$file-&gt;getClientOriginalName();
  
    $file-&gt;move($path, $name);
  
    $data=$name;
  
  }
  
  $data=array(
  
  'productname'=&gt; $request-&gt;input('productname'),
  
  'image'=&gt; $name,
  
  'price'=&gt; $request-&gt;input('price'),
  
  'category_id'=&gt; $request-&gt;input('category_id')
  
   );
  
  
  
  Product::where('id', $id)
  
    -&gt;update($data); 
  
    return redirect('/item')-&gt;with('info','Product updated successfuly!');
  
  }
  </code></pre>