Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
SitemapController
<?php
namespace App\Http\Controllers;
use App\Category;
use Sitemap;
use App\Product;
class SitemapController extends Controller
{
public function index()
{
$products = Product::where('confirmed', '=', 1)->get();
$categories = Category::orderBy('updated_at', 'desc')->get();
return response()->view('sitemap.index', [
'products' => $products,
'categories' => $categories,
])->header('Content-Type', 'text/xml');
}
public function posts()
{
$posts = Product::active()->where('confirmed', '=', 1)->get();
return response()->view('sitemap.posts', [
'posts' => $posts,
])->header('Content-Type', 'text/xml');
}
public function categories()
{
$categories = Category::all();
return response()->view('sitemap.categories', [
'categories' => $categories,
])->header('Content-Type', 'text/xml');
}
public function podcasts()
{
$podcast = Podcast::active()->orderBy('updated_at', 'desc')->get();
return response()->view('sitemap.podcasts', [
'podcasts' => $podcast,
])->header('Content-Type', 'text/xml');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.