File: D:/HostingSpaces/SBogers10/inzigd.komma.pro/app/Komma/Kms/Core/Sections/KmsSectionSubTab.php
<?php namespace App\Komma\Kms\Core\Sections;
use Illuminate\Support\MessageBag;
class KmsSectionSubTab implements KmsSectionSubTabInterface
{
protected $name;
protected $slug;
protected $items;
protected $subTabs = [];
public function __construct($name, $slug)
{
$this->items = [];
$this->name = $name;
$this->slug = $slug;
}
public function getName()
{
return $this->name;
}
public function getSlug()
{
return $this->slug;
}
public function addItem(&$item)
{
$this->items[] = $item;
}
public function getItems()
{
$items = [];
foreach ($this->items as $item) {
if ($item->checkIfUserIsEligible(\Auth::user()))
$items[] = $item;
}
return $items;
}
public function hasErrors(MessageBag $errors)
{
foreach ($this->items as $item) {
if ($errors->get($item->getKey())) return true;
}
return false;
}
public function getOrCreateSubTab($name)
{
if (!$tab = $this->getSubTabBySlug($name)) {
return $this->subTabs[] = new KmsSectionSubTab($name, $name);
}
return $tab;
}
protected function getSubTabBySlug($slug)
{
foreach ($this->subTabs as $tab) {
if ($tab->getSlug() == $slug) return $tab;
}
return null;
}
public function hasTabs()
{
return (count($this->subTabs) > 0);
}
public function getTabs()
{
return $this->subTabs;
}
}