PHPackages                             east/laravel-activityfeed - 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. east/laravel-activityfeed

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

east/laravel-activityfeed
=========================

Your Package Description here

v0.4.6(1y ago)1546MITPHP

Since Jul 5Pushed 1y ago2 watchersCompare

[ Source](https://github.com/eastbg/laravel-activityfeed)[ Packagist](https://packagist.org/packages/east/laravel-activityfeed)[ RSS](/packages/east-laravel-activityfeed/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (10)Dependencies (7)Versions (37)Used By (0)

laravel-activityfeed
====================

[](#laravel-activityfeed)

[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)![Travis](https://camo.githubusercontent.com/08f52a01929cbadf4d019bb9d941ef1da9a33c676a4b0c525d0ba601c5ebffa6/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f656173742f6c61726176656c2d6163746976697479666565642e7376673f7374796c653d666c61742d737175617265)[![Total Downloads](https://camo.githubusercontent.com/63640d3333beecf2315b999adbe13c6850b1a8a86f1e74a3dbd9e87de904444e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f656173742f6c61726176656c2d6163746976697479666565642e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/east/laravel-activityfeed)

Install
-------

[](#install)

```
composer require east/laravel-activityfeed
```

It is strongly recommended to have Laravel Backpack Pro version installed (). The web interface for defining ruling and templates relies on Backpack and it will be hard to manage without it.

### Important note about database

[](#important-note-about-database)

This extension relies heavily on users table and requires you to have a column called "admin". The users model is published to make it easier to edit columns and relationships if you have customised the database. Note though that

```
php artisan vendor:publish --force
```

will overwrite your changes to thisAf model. So you can change this model to extend your existing user class.

#### Screenshots

[](#screenshots)

[![](screenshots/template-list.png)](screenshots/template-list.png)[![](screenshots/templating.png)](screenshots/templating.png)[![](screenshots/template-database-explorer.png)](screenshots/template-database-explorer.png)[![](screenshots/rules1.png)](screenshots/rules1.png)[![](screenshots/rules2.png)](screenshots/rules2.png)[![](screenshots/rules3.png)](screenshots/rules3.png)

#### Run installer

[](#run-installer)

```
php artisan af:install
```

Usage
-----

[](#usage)

### Available command line commands

[](#available-command-line-commands)

This will create a rule templates and corresponding template entries based on your entire database structure. Running it again will not overwrite anything, but will add any tables that were not there before.

```
php artisan af:discover_rules
```

Template, rule etc. handling interfaces is based on Laravel Backpack. It's not included with the ActivityFeed package.

```
php artisan af:install_backpack
```

### Individual notifications

[](#individual-notifications)

Best way to use ActivityFeed is to extend your base model with ActivityFeedBaseModel. This allows the rules to hook into database events directly based on the rules that are tied to database tables. You can also create notification directly. You still need to have a rule for this purpose, as rule defines the template.

```
AfNotify::setTemplate('template-slug')   // mandatory
  ->addChannel(['email'])          // additional channels
  ->setSubject('New message')      // optional, template defines this already
  ->setTarget('user')              // default: user
  ->setUser(auth()->user()->id)    // default: current user
  ->setDigest()                    // set to digest instead of notifying immediately
  ->setVars($array)                // key-value replacement
  ->setObjects(['user' => $obj1, 'company' => $obj2])      // database objects
  ->add();
```

### Model based triggering - rules

[](#model-based-triggering---rules)

Rules are tied to events in particular database tables and include the following options:

- Table name
- Event (create, update, delete)
- If it's update, which column will trigger the update
    - Change (any, based on rules)
    - Column name
    - Operator
    - Value

In addition, you can create custom rules with PHP code. These go under app/ActivityFeed/Rules/. When you do the install, an example rule will be put in place.

### Creators

[](#creators)

In addition to manually defined rules that take care of the saving, you can also use a custom save class - these are called creators. The creators go under app/ActivityFeed/Creators/. When you do the install, an example creator will be put in place.

### Targeting

[](#targeting)

Target should always be an individual user, regardless of whether it's shown on a feed or sent via some other channel(s). In addition target can be admin users. Whether a particular notification

This is where it gets slightly complicated. Let's say a database record modification/creation in *Posts* launches a notification event that should be targeted at certain group of users. Example database structure:

```
      Posts
        ↓
Recipients (pivot)
        ↓
    Recipient
        ↓
      Users
```

As pivot records don't exist when creating the Posts, we will save this event to be created as a notification by the cron job. The difficult part is on mapping the relationship chain.

### Templating

[](#templating)

Templates are in Laravel Blade format and saved to database. Templates are fed with var replacement and data replacement. Idea is that you can dump data from your database record and it's relations directly to the template. So you would define it like this:

```
You have a new notification, click here to read it.
```

So also this would work:

```
@if(isset($username) AND $username)) Hello {{$username}}! @endif
You have a new notification, click here to read it.
```

And this (provided you are sending the correct objects):

```
@if(isset($user->profile) AND $user->profile)) Hello {{$user->profile->name}}! @endif
You have a new notification, click here to read it.
```

The variable replacement happens at save time and is "blind" so you should adjust your templates accordingly.

Rules define targeting and channels.

### Forking / messing with the models

[](#forking--messing-with-the-models)

As I'm lazy, I've used the excellent model generator from krlove. You can use it like this (adjust paths obviously):

```
php artisan krlove:generate:model --base-class-name='East\LaravelActivityfeed\Models\ActivityFeedBaseModel' --namespace='East\LaravelActivityfeed\Models\ActiveModels' --output-path=../vendor/east/laravel-activityfeed/src/Models/ActiveModels/ --table-name=af_events AfEventsModel

php artisan krlove:generate:model --base-class-name='East\LaravelActivityfeed\Models\ActivityFeedBaseModel' --namespace='East\LaravelActivityfeed\Models\ActiveModels' --output-path=../vendor/east/laravel-activityfeed/src/Models/ActiveModels/ --table-name=af_rules AfRules

php artisan krlove:generate:model --base-class-name='East\LaravelActivityfeed\Models\ActivityFeedBaseModel' --namespace='East\LaravelActivityfeed\Models\ActiveModels' --output-path=../vendor/east/laravel-activityfeed/src/Models/ActiveModels/ --table-name=af_categories AfCategories

php artisan krlove:generate:model --base-class-name='East\LaravelActivityfeed\Models\ActivityFeedBaseModel' --namespace='East\LaravelActivityfeed\Models\ActiveModels' --output-path=../vendor/east/laravel-activityfeed/src/Models/ActiveModels/ --table-name=af_templates AfTemplatesModel

php artisan krlove:generate:model --base-class-name='East\LaravelActivityfeed\Models\ActivityFeedBaseModel' --namespace='East\LaravelActivityfeed\Models\ActiveModels' --output-path=../vendor/east/laravel-activityfeed/src/Models/ActiveModels/ --table-name=af_notifications AfNotificationsModel
```

### Rendering

[](#rendering)

Upon install we publish af.css to public css directory and it's included with the widgets. Alternatively you can copy it to resources/css/ and import it to your app.css. In this case make sure to set configuration option for not including the css with the widgets.

Include widgets

Available widgets:

- FeedWidget
- MenuWidget
- NotificationWidget

### Understanding the flow

[](#understanding-the-flow)

```
    Model event
        ↓
    Check rules
        ↓
    Create event
        ↓
 Cronjob (afpoll:run)
        ↓
 Create notifications (uses mapping)
        ↓
Render and/or send notification
```

As pivot records don't exist when creating the Posts, we will save this event to be created as a notification by the cron job. The difficult part is on mapping the relationship chain.

Testing
-------

[](#testing)

Run the tests with:

```
vendor/bin/phpunit
```

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

[](#contributing)

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

Security
--------

[](#security)

If you discover any security-related issues, please email  instead of using the issue tracker.

License
-------

[](#license)

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

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance36

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 82.7% 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 ~23 days

Recently: every ~54 days

Total

36

Last Release

594d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/204eb365fe0d085e5e2aa8ee8692c7896799ff50a81f4b0e1850c26764255395?d=identicon)[madviking](/maintainers/madviking)

---

Top Contributors

[![appzio](https://avatars.githubusercontent.com/u/3535303?v=4)](https://github.com/appzio "appzio (67 commits)")[![nairima](https://avatars.githubusercontent.com/u/9536652?v=4)](https://github.com/nairima "nairima (13 commits)")[![madviking](https://avatars.githubusercontent.com/u/167365?v=4)](https://github.com/madviking "madviking (1 commits)")

---

Tags

laravelnotificationsactivity feed

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/east-laravel-activityfeed/health.svg)

```
[![Health](https://phpackages.com/badges/east-laravel-activityfeed/health.svg)](https://phpackages.com/packages/east-laravel-activityfeed)
```

###  Alternatives

[stephenjude/filament-blog

Filament Blog Builder

20317.8k](/packages/stephenjude-filament-blog)[ralphjsmit/laravel-helpers

A package containing handy helpers for your Laravel-application.

13704.6k2](/packages/ralphjsmit-laravel-helpers)[datomatic/nova-detached-actions

A Laravel Nova tool to allow for placing actions in the Nova toolbar detached from the checkbox selection mechanism.

11229.2k](/packages/datomatic-nova-detached-actions)

PHPackages © 2026

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