title: Laravel - delete whole collection
body: <p>I have images for articles, and when I am updating article I would like to check if the images are the same, if not I would like to delete them but if it is possible I would like to delete the whole collection without another query, something like what I have in the code below <code>$images-&gt;delete();</code>.
  This is my function:</p>
  
  <pre><code>$images = Media::where('article_id', $article-&gt;id)-&gt;get();
  
      foreach($images as $image) {
          $article_images[] = $image-&gt;original_name;
      }
  
      foreach($files as $file) {
        $filePathArr = explode('/', $file);
        $fileName = array_pop($filePathArr);
        $originalFile = explode('-', $fileName);
        $originalFileName = array_pop($originalFile);
        $newFiles[] = $originalFileName;
      }
  
      if ($newFiles != $article_images){
        $images-&gt;delete();
      }
  </code></pre>