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/honger7.komma.pro/app/KommaApp/Services/ServiceController.php
<?php
/**
 * Created by PhpStorm.
 * User: mike
 * Date: 18/05/17
 * Time: 21:59
 */

namespace App\KommaApp\Services;


use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\View;
use DaveJamesMiller\Breadcrumbs\Facade as Breadcrumbs;
use App\KommaApp\Facades\KommaServices;

class ServiceController extends Controller
{
    /**
     * Show all services
     */
    public function index()
    {
        // Fetch all services
        $services = KommaServices::all();

        // Render breadcrumb if exists
        if( ! $breadcrumb = Breadcrumbs::renderIfExists('services')) $breadcrumb = false;

        return View::make('site.pages.services',[
            'namespace' => 'services',
            'services' => $services,
            'breadcrumb' => $breadcrumb
        ]);
    }

    /**
     * Show a service detail page
     *
     * @param $slug
     * @return
     */
    public function show($slug)
    {
        // Find service
        if( ! $service = KommaServices::serviceBySlug($slug)) \App::abort(404);

        // Find next service
        if( ! $nextService = KommaServices::nextServiceBySlug($slug)) $nextService = false;

        // Render breadcrumb if exists
        if( ! $breadcrumb = Breadcrumbs::renderIfExists('service.'.$service->slug)) $breadcrumb = false;

        // Return view to the user
        return View::make('site.pages.service',[
            // Namespace is also used for our body class.
            // Add a space so that all pages can use the 'service' class
            'namespace' => 'service ' . $service->code_name,
            'service' => $service,
            'nextService' => $nextService,
            'breadcrumb' => $breadcrumb
        ]);
    }
}