add(URL::to('/'), date("Y-m-d\TH:i:s+00:00", time()), '0.8', 'daily'); $articles = DB::select("select id, slug from blog_articles"); $tags = DB::select("select id, tag_name from blog_tags"); $categories = DB::select("select id, cate_name from blog_categories"); foreach ($articles as $article) { $url = $domain.'/'.$article->slug; $sitemap->add(URL::to($url), date("Y-m-d\TH:i:s+00:00", time()), '0.8', 'daily'); } foreach ($tags as $tag) { $url = $domain.'/tag/'.$tag->tag_name; $sitemap->add(URL::to($url), date("Y-m-d\TH:i:s+00:00", time()), '0.8', 'daily'); } foreach ($categories as $category) { $url = $domain.'/category/'.$category->cate_name; $sitemap->add(URL::to($url), date("Y-m-d\TH:i:s+00:00", time()), '0.8', 'daily'); } // generate your sitemap (format, filename) $sitemap->store('xml', 'sitemap_20200520'); } /** * Execute the console command. * * @return mixed */ public function handle() { $this->info('Generating sitemap...'); $this->generate(); } }