title: php - Call to a member function getClientOriginalName() on null and remove alert laravel
body: <p>I am newbie in Laravel so i really need some help. I want to ask when 
  I commented the part 'photo' => required why if I update without entering the photo it shows some error like  call to a member function getClientOriginalName() on null. So the real question is I want to update without entering photo and it should still to be updated.</p>
  
  <p>This is my code in Controller to upload photo</p>
  
  <pre><code>    public function update($id, UpdateBannerRequest $request)
  {
      $input = $request-&gt;all();
      //get original file name
      $filename = Input::file('photo')-&gt;getClientOriginalName();
      $input['photo'] =  $filename;
      Input::file('photo')-&gt;move($this-&gt;path, $filename);
      $banner = $this-&gt;BannerRepository-&gt;findWithoutFail($id);
  
      if (empty($banner)) {
          Flash::error('Banner not found');
  
          return redirect(route('banner.index'));
      }
  
      $banner = $this-&gt;BannerRepository-&gt;update($input, $id);
  
      Flash::success('Banner updated successfully.');
  
      return redirect(route('banner.index'));
  }
  </code></pre>
  
  <p>This is the code on my model</p>
  
  <pre><code>&lt;?php
  </code></pre>
  
  <p>namespace App\Models;</p>
  
  <p>use Eloquent as Model;
  use Illuminate\Database\Eloquent\SoftDeletes;</p>
  
  <p>class Banner extends Model
  {
      use SoftDeletes;</p>
  
  <pre><code>public $table = 'banners';
  
  
  protected $dates = ['deleted_at'];
  
  
  public $fillable = [
      'title',
      'description',
      'photo',        
      'status'
  ];
  
  protected $casts = [
      'title' =&gt; 'string',
      'description' =&gt; 'string',
      'photo' =&gt; 'string',       
      'status' =&gt; 'integer'
  ];
  
  
  
  public static $rules = [
      'title' =&gt; 'required',
      'description' =&gt; 'required',
      //'photo' =&gt; 'required',
      'status' =&gt; 'required'
  ];
  </code></pre>
  
  <p>}</p>
  
  <p><a href="https://i.stack.imgur.com/5gb8N.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5gb8N.png" alt="This is the view"></a>
  <a href="https://i.stack.imgur.com/seXnR.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/seXnR.png" alt="and This is the error"></a>  </p>