for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php namespace Anomaly\DashboardModule\Widget;
use Anomaly\DashboardModule\Widget\Contract\WidgetInterface;
use Anomaly\Streams\Platform\Entry\EntryCollection;
use Anomaly\UsersModule\User\Contract\UserInterface;
/**
* Class WidgetCollection
*
* @link http://pyrocms.com/
* @author PyroCMS, Inc. <[email protected]>
* @author Ryan Thompson <[email protected]>
*/
class WidgetCollection extends EntryCollection
{
* Return only allowed widgets.
* @return WidgetCollection
public function allowed()
/* @var UserInterface $user */
if (!$user = app('auth')->user()) {
return $this->make([]);
}
return $this->filter(
function ($widget) use ($user) {
/* @var WidgetInterface $widget */
return $user->hasAnyRole($widget->getAllowedRoles());
);
* Return only widgets that
* are pinned to the top.
* @return static
public function pinned()
function ($widget) {
return $widget->isPinned();
* Return only widgets in
* the provided column.
* @param $column
public function column($column, $over = false)
function ($widget) use ($column, $over) {
if ($widget->isPinned()) {
return false;
if ($widget->getColumn() == $column) {
return true;
if ($over && $widget->getColumn() > $column) {