File: D:/HostingSpaces/Eurotools/euro-tools.nl/app/KommaApp/Breadcrumb/BreadcrumbComposer.php
<?php
namespace App\KommaApp\Breadcrumb;
use App\KommaApp\Kms\Core\KmsInterface;
use App\KommaApp\Pages\PageService;
use Illuminate\Support\Facades\Config;
class BreadcrumbComposer {
private $pageService;
private $kms;
/**
* @return mixed
*/
public function __construct(PageService $pageService)
{
$this->pageService = $pageService;
$this->kms = \App::make(KmsInterface::class);
}
/**
* Making the breadcrumb by getting the url segments
*
* @param $view
*/
public function compose($view){
$segments = \Request::segments();
$breadCrumb = [];
$url = '';
$languages = \App::getSite()->languages;
$language_shortnames = $languages->pluck('iso_2')->toArray();
foreach ($segments as $key => $segment) {
if(in_array($segment, $language_shortnames)){
$url .= '/' . $segment;
continue;
}
$text = $segment;
$text = str_replace('-', ' ', $text);
$url .= '/' . $segment;
$breadCrumb[] = ['url_part' => $url , 'text' => $text];
}
$view->with('bread', $breadCrumb);
}
}