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/edwingovers.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;

class SitemapController extends Controller 
{


    /**
     * We only need the structure of the tree to get the pages
     * The content of the pages we can get through the links
     *
     * @param null $language
     * @return \Illuminate\Contracts\View\View|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
     */
    public function show($language = null)
    {
        // If $language isset and it doesn't match with the app getLocale redefine the application language by iso of $language
        // it probably means that the route is changed by manually changing the route
        if(isset($language) && $language !== \App::getLocale()){
            \App::changeLanguageByIso2($language);
            return \App::reload(); // Because the application has many language dependencies it better reload the whole application
        }

        $otherLanguages = [];
        foreach (\App::getSite()->languages as $siteLanguage){
            $otherLanguages[$siteLanguage->id] = (object)[
                'iso' => $siteLanguage->iso_2,
                'route' => $siteLanguage->iso_2.'/sitemap'
            ];
        }

        return \View::make('site.pages.sitemap',[
            'page' => \App::getSite()->pages()->where('lft', 1)->first(),
            'links' => $this->links,
            'otherLanguages' => $otherLanguages
        ]);
    }

    /**
     * Generate the xml sitemap
     *
     */
    public function xml()
    {
        $sitemapService = new SitemapService();
        return $sitemapService->makeSitemap();
    }
}