File: D:/HostingSpaces/SBogers10/douven.komma.pro/app/KommaApp/Sitemap/SitemapController.php
<?php
/**
* Created by PhpStorm.
* User: mike
* Date: 03/10/17
* Time: 15:24
*/
namespace App\KommaApp\Sitemap;
use App\Http\Controllers\Controller;
use App\KommaApp\Pages\Models\Page;
use App\KommaApp\Posts\Models\Post;
use App\KommaApp\Shop\Catalog\Kms\CatalogService;
use Illuminate\Http\Response;
class SitemapController extends Controller
{
private $catalogService;
public function __construct(CatalogService $catalogService)
{
parent::__construct();
$this->catalogService = $catalogService;
}
public function xml()
{
$posts = Post::where('active', 1)
->with('translation')
->get();
// Return XML response
return response()->view('site.pages.sitemap.xml', [
'posts' => $posts,
'links' => $this->links,
'items' => $this->catalogService->getAllItems(),
'categoryTree' => $this->categoryTree,
])
->header('Content-Type', 'text/xml');
}
/**
* All page urls in sitemap format
*
* @return Response
*/
public function show()
{
$page = Page::where('lft', 1)->first();
return response()->view('site.pages.sitemap.show',[
'page' => $page,
'links' => $this->links,
'categoryTree' => $this->categoryTree,
]);
}
}