PHPackages                             c4studio/notification - 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. c4studio/notification

AbandonedArchivedLibrary

c4studio/notification
=====================

Provides an interface for adding and retrieving database stored notifications.

v1.0.0(9y ago)032MITPHPPHP &gt;=5.3.0

Since Oct 11Pushed 9y ago1 watchersCompare

[ Source](https://github.com/c4studio/notification)[ Packagist](https://packagist.org/packages/c4studio/notification)[ RSS](/packages/c4studio-notification/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependencies (1)Versions (2)Used By (0)

Notification
============

[](#notification)

---

Provides an interface for adding and retrieving database stored notifications.

---

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

[](#installation)

Just place require new package for your laravel installation via composer.json

```
"c4studio/notification": "1.0.*"

```

Then simply `composer update`

### Registering to use it with laravel

[](#registering-to-use-it-with-laravel)

Add following lines to `app/config/app.php`

ServiceProvider array

```
C4studio\Notification\NotificationServiceProvider::class,
```

Alias array

```
'Notification' => C4studio\Notification\Facades\Notification::class,
```

### Publishing migrations (Laravel 5.2 and lower only)

[](#publishing-migrations-laravel-52-and-lower-only)

```
php artisan vendor:publish --provider="C4studio\Notification\NotificationServiceProvider" --tag=migrations

```

### Running migrations

[](#running-migrations)

Notification uses a database table for storage, so you'll need to run the migrations

```
php artisan migrate

```

Usage
-----

[](#usage)

### Select models which can receive notifications

[](#select-models-which-can-receive-notifications)

You must apply the HasNotifications trait to all models that will be able to receive notifications

```
class User extends Model
{
    use HasNotifications;

    ...
}
```

### Add notification using facade

[](#add-notification-using-facade)

You can add notifications using the notify() method, which take two parameters: the notification message and the recipient(s). The second parameter accepts either a model or an array/collection of models

```
Notification::notify('Notification message', Auth::user());
Notification::notify('Notification message', \App\User::all());
```

If no recipient is set, the notification will be treated as a system message, and will be attached to every user model

```
Notification::notify('Notification message');
```

### Add notification using helper function

[](#add-notification-using-helper-function)

```
notify('Message', Auth::user());
notify('Message');
```

### Retrieving notifications for a model

[](#retrieving-notifications-for-a-model)

To get notifications for a model, use the notifications relationship

```
Auth::user()->notifications;
Auth::user()->notifications()->first();
```

You can also easily get the system notifications

```
Auth::user()->notifications_system;
Auth::user()->notifications_system()->first();
```

### Marking notification as read/unread

[](#marking-notification-as-readunread)

You can mark notification as read/unread by using the markRead() and markUnread() methods. But accept the user model or user ID as a parameter. If ommitted, message will be marked for current authenticated user

```
$notification::markRead();
$notification::markRead(\App\User::first());
$notification::markUnread(1);
```

### Check if notification has been read by current user

[](#check-if-notification-has-been-read-by-current-user)

You can check if a notification has been read by the currently authenticated user, by accessing the read attribute.

```
echo $notification::read ? 'It is read' : 'It is not read';
```

### Get recipients of a notification

[](#get-recipients-of-a-notification)

You can also get all the recipients of a notification

```
$notification::recipients;
$notification::recipients->take(2)->get();
```

### Complex queries

[](#complex-queries)

For more complex queries, you can return a Builder object by using query(). Easy, right?

```
Notification::query()->orderBy('timestamp', 'desc')->take(2)->get();
```

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

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

Unknown

Total

1

Last Release

3503d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/898ce9c81a1d57129720d54f435c1439dde51a6a04c402172cc96881ca036c7c?d=identicon)[further](/maintainers/further)

### Embed Badge

![Health badge](/badges/c4studio-notification/health.svg)

```
[![Health](https://phpackages.com/badges/c4studio-notification/health.svg)](https://phpackages.com/packages/c4studio-notification)
```

###  Alternatives

[anourvalar/eloquent-serialize

Laravel Query Builder (Eloquent) serialization

11320.2M21](/packages/anourvalar-eloquent-serialize)[namu/wirechat

A Laravel Livewire messaging app for teams with private chats and group conversations.

54324.5k](/packages/namu-wirechat)[statamic-rad-pack/runway

Eloquently manage your database models in Statamic.

135192.6k5](/packages/statamic-rad-pack-runway)

PHPackages © 2026

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