How can I loop in a model? I have:
SitemapGenerator::create(config('app.url'))
->configureCrawler(function (Crawler $crawler) {
$crawler->setMaximumDepth(4);
})
->add(Url::create('https://mydomain/mycustompage/'))
->getSitemap()
->writeToFile(public_path('sitemap.xml'));
I need someway to loop this: ->add(Url::create('https://mydomain/mycustompage/'))
I want to get info from my DB like this:
$all_active_products = DB::table('products')->select('slug')->where('is_active',1)->whereNull('deleted_at')->get();
And I want something like this:
$all_active_products = DB::table('products')->select('slug')->where('is_active',1)->whereNull('deleted_at')->get();
SitemapGenerator::create(config('app.url'))
->configureCrawler(function (Crawler $crawler) {
$crawler->setMaximumDepth(4);
})
foreach ($all_active_products as $a){
->add(Url::create('https://mydomain/mycustompage/'.$a->slug))
}
->getSitemap()
->writeToFile(public_path('sitemap.xml'));
I am using this package.