PHPackages                             marshmallow/nova-user-groups - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. marshmallow/nova-user-groups

AbandonedArchivedLibrary[Utility &amp; Helpers](/categories/utility)

marshmallow/nova-user-groups
============================

A package to manage Nova User Groups in Nova

v2.1.0(3y ago)22.6kMITPHPPHP ^8.0

Since Jun 22Pushed 3y ago1 watchersCompare

[ Source](https://github.com/marshmallow-packages/nova-user-groups)[ Packagist](https://packagist.org/packages/marshmallow/nova-user-groups)[ Docs](https://github.com/marshmallow/nova-user-groups)[ GitHub Sponsors](https://github.com/marshmallow)[ RSS](/packages/marshmallow-nova-user-groups/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (3)Dependencies (10)Versions (21)Used By (0)

A package to manage Nova User Groups in Nova
============================================

[](#a-package-to-manage-nova-user-groups-in-nova)

[![Latest Version on Packagist](https://camo.githubusercontent.com/4023f8cb3bbae8ae1e67c77adbf41f34b725ac2587f6fb779ebf58233b4b67d5/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d617273686d616c6c6f772f6e6f76612d757365722d67726f7570732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/marshmallow/nova-user-groups)[![GitHub Tests Action Status](https://camo.githubusercontent.com/011962cb508b8e6cf6cef1330b8f47892198f3341df16c621c3b15da81454789/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f6d617273686d616c6c6f772f6e6f76612d757365722d67726f7570732f72756e2d74657374733f6c6162656c3d7465737473)](https://github.com/marshmallow/nova-user-groups/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/d2d7f534d12f37e1caecc3fb8c43963bddfac16800ce3a9a5755ac3cb2a73a9e/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f6d617273686d616c6c6f772f6e6f76612d757365722d67726f7570732f436865636b253230262532306669782532307374796c696e673f6c6162656c3d636f64652532307374796c65)](https://github.com/marshmallow/nova-user-groups/actions?query=workflow%3A%22Check+%26+fix+styling%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/08001428f58c67d70b7c9c17cfb39c7bc721dcec5f1acde3b0cc8722e1d56615/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d617273686d616c6c6f772f6e6f76612d757365722d67726f7570732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/marshmallow/nova-user-groups)

A package to manage Nova User Groups in Nova

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require marshmallow/nova-user-groups
```

You can publish and run the migrations with:

```
php artisan vendor:publish --provider="Marshmallow\NovaUserGroups\NovaUserGroupsServiceProvider" --tag="nova-user-groups-migrations"
php artisan migrate
```

Usage
-----

[](#usage)

Run the install command to start using this package. When you run install, this will create Nova resources so you can manage all the data in your Nova installation. It will also create an administrator user group and connect all the current Nova Resources to that group. It will also connect all existing users to this administrator group.

```
php artisan user-groups:install

php artisan user-groups:policies
```

To add an super administrator group use the -s option

```
php artisan user-groups:install -s
```

### User model

[](#user-model)

Add the `HasUserGroup` trait to you user model.

```
namespace App\Models;

use Marshmallow\NovaUserGroups\Traits\HasUserGroup;

class User extends Authenticatable
{
    use HasUserGroup;

    // ...
}
```

### Nova Resource

[](#nova-resource)

Add the `UserGroupResource` trait to your main Nova Resource.

```
namespace App\Nova;

use Laravel\Nova\Resource as NovaResource;
use Laravel\Nova\Http\Requests\NovaRequest;
use Marshmallow\NovaUserGroups\Traits\UserGroupResource;

abstract class Resource extends NovaResource
{
    use UserGroupResource;

    // ...
}
```

### User methods

[](#user-methods)

You can add methods to the user model and manage if there allowed to run these methods in Nova. Out of the box we will add three methods to the User model. These are `viewNova()`, `viewTelescope()` and `viewHorizon()`. If you wish to add a new methods to this, you need to follow the following steps.

In your config, add the method that you are going to add.

```
// config/nova-user-groups.php
return [
    'user_methods' => [
        // ...
        'impersonate' => 'Is allowed to impersonate users',
    ],
];
```

Next you will need to add the methods to your user model. And call the `allowedToRunMethod` method.

```
// app/models/user.php

namespace App\Models;

class User extends Authenticatable
{
    /**
     * Please not that the methods must start with `may` and
     * then start with a capital letter.
     */
    public function mayImpersonate()
    {
        return $this->allowedToRunMethod('impersonate');
    }
}
```

Once this is all set up, go to Nova and edit your user group. In the methods section, you will now see you new `impersonate` method. Check this to activate this method for that user group.

### Nova Service Provider

[](#nova-service-provider)

Add the `UserGroupNovaServiceProvider` trait to your `NovaServiceProvider`. Once you have done so, you will have a couple of new methods to make sure the authenticated user group is allowed to do stuff that is defined in the NovaServiceProvider.

```
namespace App\Providers;

// ..
use Marshmallow\NovaUserGroups\Traits\UserGroupNovaServiceProvider;

class NovaServiceProvider extends NovaApplicationServiceProvider
{
    use UserGroupNovaServiceProvider;

    // ...

    protected function cards()
    {
        return $this->canSeeCards([
            // Your cards go here.
        ]);
    }

    protected function dashboards()
    {
        return $this->canSeeDashboards([
            // Your cards go here.
        ]);
    }

    protected function tools()
    {
        return $this->canSeeTools([
            // Your cards go here.
        ]);
    }
}
```

Change the models and resource
------------------------------

[](#change-the-models-and-resource)

All models and resources can be overruled by changing them in you `AppServiceProvider` in the `boot` method. You can find an example below. The values in this example are the default values.

```
/**
 * Bootstrap any application services.
 *
 * @return void
 */
public function boot()
{
    NovaUserGroups::$userModel = User::class;
    NovaUserGroups::$userGroupModel = \Marshmallow\NovaUserGroups\Models\UserGroup::class;
    NovaUserGroups::$novaResourceModel = \Marshmallow\NovaUserGroups\Models\NovaResource::class;
    NovaUserGroups::$novaResourceActionModel = \Marshmallow\NovaUserGroups\Models\NovaResourceAction::class;

    NovaUserGroups::$userResource = \App\Nova\User::class;
    NovaUserGroups::$novaResource = \Marshmallow\NovaUserGroups\Nova\NovaResource::class;
    NovaUserGroups::$novaResourceAction = \Marshmallow\NovaUserGroups\Nova\NovaResourceAction::class;
}
```

Config
------

[](#config)

Some methods require additional Policy access, add a group under 'groups' with the key and name. Add the allowed methods under 'methods' with group key and the method name.

```
return [

    /*
    |--------------------------------------------------------------------------
    | Allowed Admin Groups
    |--------------------------------------------------------------------------
    |
    | This is a list of groups on which the methods will be defined.
    |
    */
    'groups' => [
        'admin' => 'Administrator',
        'super-admin' => 'SuperAdministrator',
    ],

    /*
    |--------------------------------------------------------------------------
    | Allowed Methods
    |--------------------------------------------------------------------------
    |
    | This is a list of allowed methods per group
    |
    */
    'methods' => [
        'admin' => [
            'viewNova',
        ],
        'super-admin' => [
            'viewNova',
            'viewTelescope',
            'viewHorizon'
        ]
    ],
];

## Commands

```bash
php artisan user-groups:policies
php artisan user-groups:policy {name}
php artisan user-groups:import-resources

php artisan marshmallow:resource NovaTool NovaUserGroups --force
php artisan marshmallow:resource UserGroup NovaUserGroups --force
php artisan marshmallow:resource NovaResource NovaUserGroups --force
php artisan marshmallow:resource NovaResourceAction NovaUserGroups --force
```

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](.github/CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Stef van Esch](https://github.com/marshmallow-packages)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity19

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor1

Top contributor holds 67.5% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~33 days

Recently: every ~132 days

Total

18

Last Release

1216d ago

Major Versions

v1.3.0 → v2.0.02022-05-17

### Community

Maintainers

![](https://www.gravatar.com/avatar/be33d2624e24c516e73892b0929447cc762f3622c024ab8d0d2a59042e5d2c7f?d=identicon)[marshmallow](/maintainers/marshmallow)

---

Top Contributors

[![stefvanesch](https://avatars.githubusercontent.com/u/46725619?v=4)](https://github.com/stefvanesch "stefvanesch (27 commits)")[![LTKort](https://avatars.githubusercontent.com/u/2412670?v=4)](https://github.com/LTKort "LTKort (13 commits)")

---

Tags

laravelmarshmallownova-user-groups

###  Code Quality

TestsPHPUnit

Static AnalysisPsalm

Type Coverage Yes

### Embed Badge

![Health badge](/badges/marshmallow-nova-user-groups/health.svg)

```
[![Health](https://phpackages.com/badges/marshmallow-nova-user-groups/health.svg)](https://phpackages.com/packages/marshmallow-nova-user-groups)
```

###  Alternatives

[spatie/laravel-data

Create unified resources and data transfer objects

1.7k28.9M627](/packages/spatie-laravel-data)[hirethunk/verbs

An event sourcing package that feels nice.

513162.9k6](/packages/hirethunk-verbs)[worksome/exchange

Check Exchange Rates for any currency in Laravel.

123544.7k](/packages/worksome-exchange)[ralphjsmit/livewire-urls

Get the previous and current url in Livewire.

82270.3k4](/packages/ralphjsmit-livewire-urls)[hydrat/filament-table-layout-toggle

Filament plugin adding a toggle button to tables, allowing user to switch between Grid and Table layouts.

6292.3k1](/packages/hydrat-filament-table-layout-toggle)[ralphjsmit/laravel-helpers

A package containing handy helpers for your Laravel-application.

13704.6k2](/packages/ralphjsmit-laravel-helpers)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
