for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php namespace Arcanesoft\Sidebar;
use Illuminate\Support\Collection;
/**
* Class SidebarCollection
*
* @package Arcanesoft\Sidebar
* @author ARCANEDEV <[email protected]>
*/
class SidebarCollection extends Collection
{
/* -----------------------------------------------------------------
| Main Methods
| -----------------------------------------------------------------
* Push multiple sidebar items into the collection.
* @param array $items
* @return $this
public function pushSidebarItems(array $items)
foreach ($items as $item) {
$this->pushSidebarItem($item);
}
return $this;
* Push a new sidebar item to the collection.
* @param array $attributes
public function pushSidebarItem(array $attributes)
return $this->push(new SidebarItem($attributes));
* Set the selected item.
* @param string $name
public function setSelected(string $name)
return $this->transform(function (SidebarItem $item) use ($name) {
return $item->setSelected($name);
});
* Check if there is any item selected.
* @return bool
public function hasAnySelected() : bool
return $this->filter(function (SidebarItem $item) {
return $item->isActive();
})->isNotEmpty();