PHPackages                             inpin/lara-alert - 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. [Database &amp; ORM](/categories/database)
4. /
5. inpin/lara-alert

ActivePackage[Database &amp; ORM](/categories/database)

inpin/lara-alert
================

Add Alertable trait to Laravel Eloquent models

1.0.2(8y ago)3910MITPHPPHP &gt;=7.0

Since Jun 4Pushed 7y ago1 watchersCompare

[ Source](https://github.com/inpin/lara-alert)[ Packagist](https://packagist.org/packages/inpin/lara-alert)[ RSS](/packages/inpin-lara-alert/feed)WikiDiscussions master Synced 2w ago

READMEChangelog (3)Dependencies (8)Versions (5)Used By (0)

LaraAlert
=========

[](#laraalert)

[![Build Status](https://camo.githubusercontent.com/faa3e1edd1bded12b4a101ebba0ba55136609a3fc3de745462a75181d10c7a5b/68747470733a2f2f7472617669732d63692e6f72672f696e70696e2f6c6172612d616c6572742e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/inpin/lara-alert)[![StyleCI](https://camo.githubusercontent.com/ce7d27d88d1d82a8a96ce35bf172732f7c3a4b7c2f9dbf963c111a96878e1229/68747470733a2f2f6769746875622e7374796c6563692e696f2f7265706f732f3133363030393937362f736869656c643f6272616e63683d6d6173746572)](https://github.styleci.io/repos/136009976)[![Maintainability](https://camo.githubusercontent.com/87a45d100ab2295a5fed8f5f2e9ed13f707be081cbe043375f8e258eb72bd3fb/68747470733a2f2f6170692e636f6465636c696d6174652e636f6d2f76312f6261646765732f38616333653065613063363332343838306338652f6d61696e7461696e6162696c697479)](https://codeclimate.com/github/inpin/lara-alert/maintainability)[![Latest Stable Version](https://camo.githubusercontent.com/016de1550824d737f2a8681060e49719d7752ef3d442dfb472af27d4d6dc9053/68747470733a2f2f706f7365722e707567782e6f72672f696e70696e2f6c6172612d616c6572742f762f737461626c65)](https://packagist.org/packages/inpin/lara-alert)[![Total Downloads](https://camo.githubusercontent.com/82392effc500f14b8eac7249fc69ee8a06ab30bd5e56887308fe4a89b89d06fc/68747470733a2f2f706f7365722e707567782e6f72672f696e70696e2f6c6172612d616c6572742f646f776e6c6f616473)](https://packagist.org/packages/inpin/lara-alert)[![Latest Unstable Version](https://camo.githubusercontent.com/f8b01f93f86fdc4cf820fa0c9e0e8994eb82946b31f2954b81843b2ac54fee11/68747470733a2f2f706f7365722e707567782e6f72672f696e70696e2f6c6172612d616c6572742f762f756e737461626c65)](https://packagist.org/packages/inpin/lara-alert)[![License](https://camo.githubusercontent.com/5b1986f127462b1bc32f0342b8fbacf3ea5fc0ddbaaec8ff584e7350920ba6e0/68747470733a2f2f706f7365722e707567782e6f72672f696e70696e2f6c6172612d616c6572742f6c6963656e7365)](https://packagist.org/packages/inpin/lara-alert)

Trait for Laravel Eloquent models to allow easy implementation of a "user alerts" feature.

#### Composer Install (for Laravel 5.5 and above)

[](#composer-install-for-laravel-55-and-above)

```
composer require inpin/lara-alert

```

#### Install and then run the migrations

[](#install-and-then-run-the-migrations)

```
'providers' => [
    \Inpin\LaraAlert\LaraAlertServiceProvider::class,
],
```

```
php artisan vendor:publish --provider="Inpin\LaraAlert\LaraAlertServiceProvider" --tag=migrations
php artisan migrate
```

#### Model and database schema

[](#model-and-database-schema)

it will create you a table of `laraalert_alerts` with following fields:

`type` is the type of alert, ex: 'alert', 'confirmation complete', 'software update, etc.

`description` a nullable text which describe alert.

`seen_at` determines if current alert is new (seen\_at is null\_) or not (seen\_at fills with timestamp)

#### Setup your models

[](#setup-your-models)

```
class Book extends \Illuminate\Database\Eloquent\Model {
    use Inpin\LaraAlert\Alertable;
}
```

#### Sample Usage

[](#sample-usage)

```
// Create an alert with type of 'alert' by currently logged in user without description.
$book->createAlert();

// Create a alert on $book object with type of "some-alert-type", and null description.
$book->createAlert('some-alert-type');

// Create a alert on $book object with type of "some-alert-type", null description,
// and current logged in user form 'api' guard as owner.
$book->createAlert('some-alert-type', 'api');

// Create a alert on $book object with type of "some-alert-type", null description, and $user as owner.
$book->createAlert('some-alert-type', $user);

// Create a alert on $book object with type of "some-alert-type", with description of "some message,
// and current logged in user form 'api' guard as owner.
$book->createAlert('some-alert-type', 'api', 'some message');

// Create a alert on $book object with type of "some-alert-type", with description of "some message,
// and current logged in user form 'api' guard as owner.
$book->createAlert('some-alert-type', $user, 'some message');

// Create a alert on $book object with "alert item id" of 1 and 2, put user message of "some message on it",
// and put $user (3rd param) as alerter.
$book->createAlert([1, 2], 'some message', $user');

$book->alerts(); // HasMany relation to alerts of book.
$book->alerts; // Collection of book's alerts.

$book->isAlertedBy() // check if current logged in user form default guard has alerted book.
$book->isAlertedBy('api') // check if current logged in user form 'api' guard has alerted book.
$book->isAlertedBy($user) // check if '$user' has alerted book.

$book->isAlerted() // check if $book has alert.
$book->isAlerted // check if $book has alert.

$book->alertsCount; // return number of alerts on $book.
$book->alertsCount(); // return number of alerts on $book.
```

Alert objects

```
// set seen_at with current timestamp.
$alert->seen();

// check if $alert is new or not.
$alert->isNew();
$alert->isNew;

// check if $alert is seen or not.
$alert->isSeen();
$alert->isSeen;
```

#### Credits

[](#credits)

- Mohammad Nourinik -

###  Health Score

29

—

LowBetter than 57% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 100% 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 ~4 days

Total

3

Last Release

2939d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/17546136?v=4)[Mohammad Nourinik](/maintainers/enourinick)[@enourinick](https://github.com/enourinick)

---

Top Contributors

[![enourinick](https://avatars.githubusercontent.com/u/17546136?v=4)](https://github.com/enourinick "enourinick (6 commits)")

---

Tags

alertauthlaravelnotificationnotifyphppushuserlaravelpushnotificationeloquenttraitstorelaravel5alertalertablepush-notify

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/inpin-lara-alert/health.svg)

```
[![Health](https://phpackages.com/badges/inpin-lara-alert/health.svg)](https://phpackages.com/packages/inpin-lara-alert)
```

###  Alternatives

[kirschbaum-development/eloquent-power-joins

The Laravel magic applied to joins.

1.6k29.9M42](/packages/kirschbaum-development-eloquent-power-joins)[cybercog/laravel-love

Make Laravel Eloquent models reactable with any type of emotions in a minutes!

1.2k322.4k1](/packages/cybercog-laravel-love)[psalm/plugin-laravel

Psalm plugin for Laravel

3345.1M337](/packages/psalm-plugin-laravel)[watson/validating

Eloquent model validating trait.

9733.4M53](/packages/watson-validating)[rtconner/laravel-likeable

Trait for Laravel Eloquent models to allow easy implementation of a 'like' or 'favorite' or 'remember' feature.

392393.3k5](/packages/rtconner-laravel-likeable)[reedware/laravel-relation-joins

Adds the ability to join on a relationship by name.

2111.2M16](/packages/reedware-laravel-relation-joins)

PHPackages © 2026

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