urls as $url) { $sitemap->add($this->createUrl($url[0], $url[1])); } $this->addTemplatesUrls($sitemap); $this->addTemplatesTypesUrls($sitemap); $this->addTemplatesIndustriesUrls($sitemap); return $sitemap->toResponse($request); } private function createUrl($url, $priority, $frequency = 'daily') { return Url::create($url)->setPriority($priority)->setChangeFrequency($frequency); } private function addTemplatesUrls(Sitemap $sitemap) { Template::where('publicly_listed', true)->chunk(100, function ($templates) use ($sitemap) { foreach ($templates as $template) { $sitemap->add($this->createUrl('/form-templates/' . $template->slug, 0.8)); } }); } private function addTemplatesTypesUrls(Sitemap $sitemap) { $types = json_decode(file_get_contents(resource_path('data/forms/templates/types.json')), true); foreach ($types as $type) { $sitemap->add($this->createUrl('/form-templates/types/' . $type['slug'], 0.7)); } } private function addTemplatesIndustriesUrls(Sitemap $sitemap) { $industries = json_decode(file_get_contents(resource_path('data/forms/templates/industries.json')), true); foreach ($industries as $industry) { $sitemap->add($this->createUrl('/form-templates/industries/' . $industry['slug'], 0.7)); } } }