-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from ARCANESOFT/update-laravel_5.7
Adding Laravel 5.7 support
- Loading branch information
Showing
13 changed files
with
1,063 additions
and
979 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
<?php namespace Arcanesoft\Sidebar; | ||
|
||
use Illuminate\Support\Collection as BaseCollection; | ||
|
||
/** | ||
* Class Collection | ||
* | ||
* @package Arcanesoft\Sidebar | ||
* @author ARCANEDEV <[email protected]> | ||
*/ | ||
class Collection extends BaseCollection | ||
{ | ||
/* ----------------------------------------------------------------- | ||
| Main Methods | ||
| ----------------------------------------------------------------- | ||
*/ | ||
|
||
/** | ||
* Add a sidebar item. | ||
* | ||
* @param \Arcanesoft\Sidebar\Item $item | ||
* | ||
* @return $this | ||
*/ | ||
public function add(Item $item) | ||
{ | ||
return $this->push($item); | ||
} | ||
|
||
/** | ||
* Push multiple sidebar items into the collection. | ||
* | ||
* @param array $items | ||
* | ||
* @return $this | ||
*/ | ||
public function addItems(array $items) | ||
{ | ||
foreach ($items as $item) { | ||
$this->addItem($item); | ||
} | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* Push a new sidebar item to the collection. | ||
* | ||
* @param array $attributes | ||
* | ||
* @return $this | ||
*/ | ||
public function addItem(array $attributes) | ||
{ | ||
return $this->add(new Item($attributes)); | ||
} | ||
|
||
/** | ||
* Set the selected item. | ||
* | ||
* @param string $name | ||
* | ||
* @return $this | ||
*/ | ||
public function setSelected(string $name) | ||
{ | ||
return $this->transform(function (Item $item) use ($name) { | ||
return $item->setSelected($name); | ||
}); | ||
} | ||
|
||
/* ----------------------------------------------------------------- | ||
| Check Methods | ||
| ----------------------------------------------------------------- | ||
*/ | ||
|
||
/** | ||
* Check if there is any item selected. | ||
* | ||
* @return bool | ||
*/ | ||
public function hasAnySelected() : bool | ||
{ | ||
return $this->filter(function (Item $item) { | ||
return $item->isActive(); | ||
})->isNotEmpty(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.