Skip to content

Instantly share code, notes, and snippets.

@Valonix
Created January 10, 2017 09:32
Show Gist options
  • Save Valonix/7a019790dd22fe345cefa877fca55f30 to your computer and use it in GitHub Desktop.
Save Valonix/7a019790dd22fe345cefa877fca55f30 to your computer and use it in GitHub Desktop.
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