Skip to content

Commit

Permalink
Merge pull request #3 from ARCANESOFT/update-laravel_5.7
Browse files Browse the repository at this point in the history
Adding Laravel 5.7 support
  • Loading branch information
arcanedev-maroc authored Feb 13, 2019
2 parents 890b958 + 20afc4e commit e7da076
Show file tree
Hide file tree
Showing 13 changed files with 1,063 additions and 979 deletions.
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@
"license": "MIT",
"require": {
"php": ">=7.1.3",
"arcanedev/support": "~4.3.0",
"ext-json": "*",
"arcanedev/support": "~4.4.0",
"arcanesoft/contracts": "~2.1.0"
},
"require-dev": {
"phpunit/phpunit": "~7.0",
"phpunit/phpcov": "~5.0",
"symfony/dom-crawler": "~3.4.0",
"orchestra/testbench": "~3.6.0"
"orchestra/testbench": "~3.7.0"
},
"autoload": {
"psr-4": {
Expand Down
88 changes: 88 additions & 0 deletions src/Collection.php
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();
}
}
75 changes: 27 additions & 48 deletions src/Contracts/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,94 +14,66 @@ interface Manager
*/

/**
* Set the view name.
* Set the selected item.
*
* @param string $view
* @param string $name
*
* @return $this
*/
public function setView($view);

/**
* Get the current item name.
*
* @return string
*/
public function getCurrent();

/**
* Set the current item name.
*
* @param string $currentName
*
* @return $this
*/
public function setCurrent($currentName);
public function setSelectedItem(string $name);

/**
* Get the sidebar items.
*
* @return \Arcanesoft\Sidebar\Entities\ItemCollection
* @return \Arcanesoft\Sidebar\Collection
*/
public function getItems();
public function items();

/* -----------------------------------------------------------------
| Main Methods
| -----------------------------------------------------------------
*/

/**
* Add a routed item.
* Add an item from array.
*
* @param string $name
* @param string $title
* @param string $route
* @param array $parameters
* @param string|null $icon
* @param array $array
*
* @return $this
*/
public function addRouteItem($name, $title, $route, array $parameters = [], $icon = null);
public function add(array $array);

/**
* Add an item.
* Load items from array.
*
* @param string $name
* @param string $title
* @param string $url
* @param string|null $icon
* @param array $array
*
* @return $this
* @return mixed
*/
public function addItem($name, $title, $url = '#', $icon = null);
public function loadFromArray(array $array);

/**
* Add an item from array.
* Load items from multiple config keys.
*
* @param array $array
* @param string $key
*
* @return $this
*/
public function add(array $array);
public function loadFromConfig($key);

/**
* Load items from multiple config keys.
*
* @param string $key
* Show the sidebar.
*
* @return $this
*/
public function loadItemsFromConfig($key);
public function show();

/**
* Render the sidebar.
* Hide the sidebar.
*
* @param string|null $view
* @param array $data
*
* @return \Illuminate\Support\HtmlString
* @return $this
*/
public function render($view = null, array $data = []);
public function hide();

/* -----------------------------------------------------------------
| Check Methods
Expand All @@ -114,4 +86,11 @@ public function render($view = null, array $data = []);
* @return bool
*/
public function hasItems();

/**
* Check if the sidebar is shown.
*
* @return bool
*/
public function isShown();
}
Loading

0 comments on commit e7da076

Please sign in to comment.