PHPackages                             marshmallow/nova-activity - 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-activity

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

marshmallow/nova-activity
=========================

A Laravel Nova field.

v5.2.1(7mo ago)02.0k↓60%MITVuePHP ^8.1

Since Dec 7Pushed 3w ago2 watchersCompare

[ Source](https://github.com/marshmallow-packages/nova-activity)[ Packagist](https://packagist.org/packages/marshmallow/nova-activity)[ RSS](/packages/marshmallow-nova-activity/feed)WikiDiscussions main Synced today

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

[![alt text](https://camo.githubusercontent.com/f5450f299f5713ce2f04dd5a1ba7ce9960ed4568b3574e4c4ee3cddc75477253/68747470733a2f2f6d617273686d616c6c6f772e6465762f63646e2f6d656469612f6c6f676f2d7265642d3233377834362e706e67 "marshmallow.")](https://camo.githubusercontent.com/f5450f299f5713ce2f04dd5a1ba7ce9960ed4568b3574e4c4ee3cddc75477253/68747470733a2f2f6d617273686d616c6c6f772e6465762f63646e2f6d656469612f6c6f676f2d7265642d3233377834362e706e67)

Nova Activity
=============

[](#nova-activity)

[![Latest Version on Packagist](https://camo.githubusercontent.com/ba1989b369f23c75f08e01e2b82ce43728bae3dfc07f3af4e8c1311f4d5ed330/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d617273686d616c6c6f772f6e6f76612d61637469766974792e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/marshmallow/nova-activity)[![Total Downloads](https://camo.githubusercontent.com/6c0e6e992173b8b1aa1e0defa92b581bd6150ff976505eb0f2551b055968d16d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d617273686d616c6c6f772f6e6f76612d61637469766974792e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/marshmallow/nova-activity)

A Laravel Nova field that adds a timeline of activities, comments and quick replies to a resource. Activities are stored as a polymorphic relation on your own models, support mentions, file uploads, custom actions and emit events for every interaction.

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

[](#installation)

Install the package via Composer:

```
composer require marshmallow/nova-activity
```

Publish and run the migrations:

```
php artisan vendor:publish --tag="nova-activity-migrations"
php artisan migrate
```

Publish the config file:

```
php artisan vendor:publish --tag="nova-activity-config"
```

Optionally publish the translations:

```
php artisan vendor:publish --tag="nova-activity-translations"
```

Setup
-----

[](#setup)

Add the `NovaActivities` trait to any model that should record activities:

```
use Marshmallow\NovaActivity\Traits\NovaActivities;

class Order extends Model
{
    use NovaActivities;
}
```

Add the `Activity` field to the corresponding Nova resource:

```
use Marshmallow\NovaActivity\Activity;

public function fields(NovaRequest $request)
{
    return [
        Activity::make(__('Activity'))
            ->types(function () {
                return [
                    1 => 'Called the customer and spoke to them.',
                    2 => 'Customer will send additional information.',
                ];
            })
            ->showOnPreview(),
    ];
}
```

When the `Activity` field is shown on the index view, add the following to the resource so the row click action does not interfere with the field:

```
public static $clickAction = 'ignore';
```

Configuration
-------------

[](#configuration)

The published `config/nova-activity.php` file exposes the following options:

KeyDefaultDescription`table_name``nova_activity`Table used to store activities.`use_quick_replies``true`Enable the quick-reply (reaction) buttons.`use_comments``true`Allow writing comments on activities.`use_file_uploads``false`Allow attaching file uploads to activities.`dates.format``d M, Y \a\t H:i`PHP date format.`dates.js_format``Do MMM, YYYY`moment.js date format used in the field UI.`dates.use_human_readable``true`Render dates as human-readable, relative strings.`comment_validation.type``required`Validation rule applied to the comment input.`quick_replies`array of reactionsThe available quick replies (name, background, icon, solid\_icon).Each quick reply is defined as:

```
'quick_replies' => [
    'exited' => [
        'name' => 'Exited',
        'background' => '#ef4444',
        'icon' => 'fire',
        'solid_icon' => false,
    ],
    // ...
],
```

Usage
-----

[](#usage)

### Adding activities from code

[](#adding-activities-from-code)

The `NovaActivities` trait adds an `addActivity()` method to your model:

```
use Carbon\Carbon;

$model->addActivity(
    user_id: $request->user()->id,
    type: $request->type,
    label: $request->type_label,
    comment: $request->comment,
    created_at: Carbon::parse($request->date),
    quick_replies: [
        'user_1' => 'sad',
    ],
    mentions: [
        [
            'key' => 1,
            'class' => User::class,
        ],
    ],
);
```

All arguments are optional; only the ones you pass are stored.

### Field options

[](#field-options)

The `Activity` field exposes a fluent API. All of the methods below return the field instance so they can be chained:

```
Activity::make(__('Activity'))
    ->activityTitle('Activity title')   // pass null to hide the title
    ->useComments(true)
    ->useQuickReplies(true)
    ->useFileUploads(true)
    ->useHumanReadableDates(true)
    ->alwaysShowComments()
    ->truncateComments(100)
    ->jsDateFormat('Do MMM, YYYY')       // moment.js format
    ->setLocale('nl');
```

`setLocale()` also accepts a closure:

```
->setLocale(function () {
    return auth()->user()->locale;
})
```

### Limiting the number of activities shown

[](#limiting-the-number-of-activities-shown)

```
->limit(3)            // limit on index, detail and forms
->limitOnDetail(null) // null shows all
->limitOnIndex(3)
->limitOnForms(10)
```

### Types

[](#types)

`types()` accepts an array or a closure mapping a value to a label:

```
->types(function () {
    return [
        2 => 'Called the customer and spoke to them.',
    ];
})
```

### Mentions

[](#mentions)

Provide the list of mentionable users with `mentions()`:

```
->mentions(function (): array {
    return User::get()->map(function ($user) {
        return [
            'model' => $user,
            'value' => str_slug($user->name),
            'avatar_url' => Activity::getUserAvatar($user),
            'key' => $user->name,
        ];
    })->toArray();
})
```

On a stored activity you can inspect the mentions:

```
/** Check if this activity has any mentions. */
$activity->hasMentions();

/** Get a collection of all the classes that were mentioned. */
$activity->getMentions();
```

### Avatars

[](#avatars)

`Activity::getUserAvatar($user)` falls back to a Gravatar based on the user's email. To use a custom avatar, add an `avatarPath()` method to your user model:

```
// App\Models\User
public function avatarPath()
{
    return 'https://example.com/avatars/me.jpg';
}
```

### Custom actions

[](#custom-actions)

Attach actions to the field with `actions()`:

```
use Marshmallow\NovaActivity\Actions\ToggleTagAction;

->actions([
    ToggleTagAction::make(__('Important'), 'important')
        ->color('red')
        ->backgroundColor('#ffffff')
        ->borderColor('red')
        ->icon('fire'),
])
```

Events
------

[](#events)

Every interaction dispatches an event. Listen for them in your `EventServiceProvider`:

```
use App\Listeners\DoWhatEver;
use Marshmallow\NovaActivity\Events\ActivityCreated;

protected $listen = [
    ActivityCreated::class => [
        DoWhatEver::class,
    ],
];
```

The available events are:

EventPublic properties`ActivityCreated``$activity``ActivityDeleted``$activity`, `$user``ActivityPinned``$activity`, `$user``ActivityUnpinned``$activity`, `$user``ActivityCommentHidden``$activity`, `$user``ActivityCommentShow``$activity`, `$user``QuickReplyChanged``$activity`, `$user`Inside a listener you can reach the activity and the model it belongs to:

```
class DoWhatEver
{
    public function handle($event)
    {
        /** The model on which the activity was created. */
        $model = $event->activity->nova_activity;

        /** The activity itself. */
        $activity = $event->activity;

        /** Mentions. */
        $activity->hasMentions();
        $activity->getMentions();
    }
}
```

Credits
-------

[](#credits)

- [Marshmallow](https://github.com/marshmallow-packages)
- [All Contributors](https://github.com/marshmallow-packages/nova-activity/contributors)

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

[](#security-vulnerabilities)

Please report security vulnerabilities by email rather than via the public issue tracker.

License
-------

[](#license)

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

###  Health Score

46

—

FairBetter than 92% of packages

Maintenance81

Actively maintained with recent releases

Popularity19

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 80% 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 ~35 days

Recently: every ~59 days

Total

21

Last Release

227d ago

Major Versions

v0.0.11 → v1.0.02024-08-16

v1.0.0 → v5.0.02025-03-02

v1.0.1 → v5.2.02025-08-07

PHP version history (2 changes)v0.0.2PHP ^7.3|^8.0

v5.0.0PHP ^8.1

### 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 (72 commits)")[![LTKort](https://avatars.githubusercontent.com/u/2412670?v=4)](https://github.com/LTKort "LTKort (18 commits)")

---

Tags

laravelnova

### Embed Badge

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

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

###  Alternatives

[optimistdigital/nova-multiselect-field

A multiple select field for Laravel Nova.

3453.7M8](/packages/optimistdigital-nova-multiselect-field)[optimistdigital/nova-sortable

This Laravel Nova package allows you to reorder models in a Nova resource's index view using drag &amp; drop.

2852.1M6](/packages/optimistdigital-nova-sortable)[outl1ne/nova-sortable

This Laravel Nova package allows you to reorder models in a Nova resource's index view using drag &amp; drop.

2862.1M9](/packages/outl1ne-nova-sortable)[outl1ne/nova-settings

A Laravel Nova tool for editing custom settings using native Nova fields.

2971.0M3](/packages/outl1ne-nova-settings)[optimistdigital/nova-menu-builder

This Laravel Nova package allows you to create and manage menus and menu items.

243377.1k](/packages/optimistdigital-nova-menu-builder)[outl1ne/nova-menu-builder

This Laravel Nova package allows you to create and manage menus and menu items.

243268.1k4](/packages/outl1ne-nova-menu-builder)

PHPackages © 2026

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