title: How to update multiple image and remove old images in Laravel 5.4?
body: <p>It is difficult for me to update and replace several images. How to save multiple images, I understand, but I can not update and remove old images. </p>
  
  <ul>
  <li>The are 3 tables:
  
  <ul>
  <li>portfolios</li>
  <li>photos</li>
  <li>portfolio_photo (pivot)</li>
  </ul></li>
  </ul>
  
  <p>HTML Form Update</p>
  
  <pre><code>{!! Form::model($portfolio, ['route' =&gt; ['portfolio.update', $portfolio-&gt;id], 'method' =&gt; 'PUT', 'files' =&gt; 'true' ]) !!}
      &lt;input type="file" id="portfolio_photos" name="portfolio_photos[]" class="form-control" multiple&gt;
  {{!! Form::close() !!}}
  </code></pre>
  
  <p>Controller, I do not know how to do a method update.</p>
  
  <pre><code>    public function store(PortfolioValidation $request){
  
        $portfolio = new Portfolio();
        $portfolio-&gt;portfolio_title = $request-&gt;portfolio_title;
        $portfolio-&gt;portfolio_slug = str_slug($request-&gt;portfolio_title);
        $portfolio-&gt;apartment_project = $request-&gt;apartment_project;
        $portfolio-&gt;apartment_area = $request-&gt;apartment_area;
        $portfolio-&gt;type_repair = $request-&gt;type_repair;
        $portfolio-&gt;year_implementation = $request-&gt;year_implementation;
        $portfolio-&gt;deadline = $request-&gt;deadline;
        $portfolio-&gt;save();
  
        if($request-&gt;hasFile('portfolio_photos')){
           foreach($request-&gt;portfolio_photos as $portfolio_photo){
              $fileName = rand() . '.' . $portfolio_photo-&gt;getClientOriginalExtension();
              $path = public_path('img/portfolio/' . $fileName);
              Image::make($portfolio_photo)-&gt;resize(1280, 960)-&gt;save($path);
              $newFile = new Photo();
              $newFile-&gt;portfolio_photos = $fileName;
              $newFile-&gt;save();
              $portfolio-&gt;photos()-&gt;save($newFile);
           }
        }
        Session::flash('success', 'Success!');
        return redirect()-&gt;route('portfolio.index');
     }
  </code></pre>