title: laravel-5.4 - error :Creating default object from empty value
body: <p>I want to store image path in database. My Controller code under<code>vendor\laravel\framework\src\Illuminate\Foundation\Auth\RegistersUsers.php</code> follows:</p>
  
  <pre><code>public function register(Request $request)
  {
      $this-&gt;validator($request-&gt;all())-&gt;validate();
  
      if($request-&gt;hasFile('image')) {
      $image_name = $request-&gt;file('image')-&gt;getClientOriginalName();              
      $image_path = $request-&gt;file('image')-&gt;store('public'); 
      $user-&gt;image = Storage::url($image_name);
      $user-&gt;save();
      }
  
      event(new Registered($user = $this-&gt;create($request-&gt;all())));
  
     // $this-&gt;guard()-&gt;login($user); disable autologin for new users
  
      return $this-&gt;registered($request, $user)
                      ?: redirect($this-&gt;redirectPath());
  }
  </code></pre>
  
  <p>I am getting the following error: ErrorException in RegistersUsers.php line 40: Creating default object from empty value <a href="https://i.stack.imgur.com/Yf3bz.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/Yf3bz.jpg" alt="enter image description here"></a>.</p>
  
  <p>The  image is getting saved in public folder but not able to save image path in the user table database. schema of user table<br>
        <code>Schema::create('users', function (Blueprint $table) {
              $table-&gt;increments('user_id');
              $table-&gt;string('name');
              $table-&gt;string('image');
              $table-&gt;rememberToken();
              $table-&gt;timestamps();</code></p>
  
  <p>how to proceed to store the image path in the user table in database</p>