sitemap.index looks like this:
<?php
use Vanilo\Product\Models\Product;
header('Content-Type: text/xml');
?>
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<?php Product::all()->each(function($product) {
echo "<url><loc>";
echo route('product.show', $product);
echo "</loc><lastmod>";
echo \Carbon\Carbon::now();
echo "</lastmod><changefreq>monthly</changefreq><priority>0.8</priority$
}); ?>
</urlset>
web.php looks like this where my route is:
Route::get('/sitemap', function() {
return view('sitemap.index')->withHeaders([
'Content-Type' => 'text/xml'
]);
});
However, My page comes out like this:
https://evosmedia.uk/shop/p/blk-med-tshirt2019-07-21 08:33:54monthly0.8https://evosmedia.uk/shop/p/small-black-tshirt2019-07-21 08:33:54monthly0.8
How can I render the route as XML?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire