HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
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,
        ]);
    }

}