title: I need a loop inside a model query
body: <p>How can I loop in a model?
  I have:</p>
  <pre><code>SitemapGenerator::create(config('app.url'))
  -&gt;configureCrawler(function (Crawler $crawler) {
         $crawler-&gt;setMaximumDepth(4);
    })
  -&gt;add(Url::create('https://mydomain/mycustompage/'))
  -&gt;getSitemap()
  -&gt;writeToFile(public_path('sitemap.xml'));     
  </code></pre>
  <p>I need someway to loop this: <code>-&gt;add(Url::create('https://mydomain/mycustompage/'))</code><br />
  I want to get info from my DB like this:</p>
  <pre><code>$all_active_products =  DB::table('products')-&gt;select('slug')-&gt;where('is_active',1)-&gt;whereNull('deleted_at')-&gt;get();
  </code></pre>
  <p>And I want something like this:</p>
  <pre><code>$all_active_products =  DB::table('products')-&gt;select('slug')-&gt;where('is_active',1)-&gt;whereNull('deleted_at')-&gt;get();
  SitemapGenerator::create(config('app.url'))
      -&gt;configureCrawler(function (Crawler $crawler) {
          $crawler-&gt;setMaximumDepth(4);
     })
     foreach ($all_active_products as $a){
        -&gt;add(Url::create('https://mydomain/mycustompage/'.$a-&gt;slug))
     }
  
     -&gt;getSitemap()
     -&gt;writeToFile(public_path('sitemap.xml'));  
  </code></pre>
  <p>I am using <a href="https://github.com/spatie/laravel-sitemap" rel="nofollow noreferrer">this package</a>.</p>