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
]);
}
}