PHPackages                             fahedaljghine/laravel-model-note - 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. fahedaljghine/laravel-model-note

ActiveLibrary

fahedaljghine/laravel-model-note
================================

A package to enable assigning notes to Eloquent Models

1.0.2(3y ago)2508MITPHPPHP ^8.0

Since May 8Pushed 3y ago1 watchersCompare

[ Source](https://github.com/fahedaljghine/laravel-model-note)[ Packagist](https://packagist.org/packages/fahedaljghine/laravel-model-note)[ Docs](https://github.com/fahedaljghine/laravel-model-note)[ RSS](/packages/fahedaljghine-laravel-model-note/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (3)Dependencies (3)Versions (4)Used By (0)

Add notes to Eloquent models
============================

[](#add-notes-to-eloquent-models)

This package provides a `HasNotes` trait that, once installed on a model, allows you to do things like this:

```
// add a note
$model->addNote('needs manager approve');

// add another note
$model->addNote('manager approved');

// get the current status
$model->notes(); // returns a collection of \Fahedaljghine\ModelNotes\Note

// get the last note
$lastNote = $model->lastNote(); // returns an instance of \Fahedaljghine\ModelNotes\Note
```

Contact Me
----------

[](#contact-me)

You can check all of my information by [Checking my website](https://fahedaljghine.com/).

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

[](#installation)

You can install the package via composer:

```
composer require fahedaljghine/laravel-model-note
```

You must publish the migration with:

```
php artisan vendor:publish --provider="Fahedaljghine\ModelNote\ModelNoteServiceProvider" --tag="migrations"
```

Migrate the `notes` table:

```
php artisan migrate
```

Optionally you can publish the config-file with:

```
php artisan vendor:publish --provider="Fahedaljghine\ModelNote\ModelNoteServiceProvider" --tag="config"
```

This is the contents of the file which will be published at `config/model-note.php`

```
return [

    /*
     * The class name of the notes model that holds all notes.
     *
     * The model must be or extend `Fahedaljghine\ModelNote\Note`.
     */
    'note_model' => Fahedaljghine\ModelNote\Note::class,

    /*
     * The name of the column which holds the ID of the model related to the notes.
     *
     * You can change this value if you have set a different name in the migration for the notes table.
     */
    'model_primary_key_attribute' => 'model_id',

];
```

Usage
-----

[](#usage)

Add the `HasNotes` trait to a model you like to use notes on.

```
use Fahedaljghine\ModelNote\HasNotes;

class YourEloquentModel extends Model
{
    use HasNotes;
}
```

### Add a new note

[](#add-a-new-note)

You can add a new note like this:

```
$model->addNote('whatever you like');
```

### Add a private note

[](#add-a-private-note)

You can add a new private note which can be seen only be you like this:

```
$model->addNote('whatever you like' , true);

//or alternatively
$model->addPrivateNote('whatever you like');
```

### Add a note with tag

[](#add-a-note-with-tag)

Sometimes you will need to tag your note with some tag which can be done like this:

```
$model->addNote('whatever you like' , false , "tag1");

//or for the private note
$model->addPrivateNote('whatever you like' , "tag2");
```

### Retrieving notes

[](#retrieving-notes)

You can get the last note of model:

```
$model->note; // returns the text of the last note

$model->note(); // returns the last instance of `Fahedaljghine\ModelNote\Note`

//or alternatively
$model->lastNote(); // returns the last instance of `Fahedaljghine\ModelNote\Note`
```

All associated notes of a model can be retrieved like this:

```
$all_notes = $model->notes;

//or alternatively
$all_notes = $model->notes();
```

All associated notes of a model with specific tag or tags can be retrieved like this:

```
//last note of specific tag
$last_note = $model->lastNote("tag1");

//specific tag
$all_notes = $model->allNotes("tag1");

//specific tags
$all_notes = $model->allNotes("tag1" , "tag2");
```

All associated private notes of a model with specific tag or tags can be retrieved like this:

```
//specific tag
$all_notes = $model->privateNotes("tag1");

//specific tags
$all_notes = $model->privateNotes("tag1" , "tag2");
```

### Delete a note from model

[](#delete-a-note-from-model)

You can delete any note that has been added on the model by id at any time by using the `deleteNote` method:

```
//specific id
$model->deleteNote(1);

//specific ides
$model->deleteNote(1, 2, 3);
```

You can delete any note that has been added on the model by tag at any time by using the `deleteNote` method:

```
//specific tag
$model->deleteNoteByTag("tag1");

//specific tags
$model->deleteNoteByTag("tag1", "tag2", "tag3");
```

### Delete all notes from model

[](#delete-all-notes-from-model)

You can delete all notes that had been added on the model at any time by using the `deleteAllNotes` method:

Delete all notes from model:

```
$model->deleteAllNotes();
```

### Custom model and migration

[](#custom-model-and-migration)

You can change the model used by specifying a class name in the `note_model` key of the `model-note` config file.

You can change the column name used in the notes table (`model_id` by default) when using a custom migration where you changed that. In that case, simply change the `model_primary_key_attribute` key of the `model-note` config file.

### Changelog

[](#changelog)

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

Dontae
------

[](#dontae)

- [Paypal](https://www.paypal.com/donate/?hosted_button_id=MSKWTL27YPFDW)

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

[](#contributing)

You are welcome to contribute

Credits
-------

[](#credits)

- [Fahed Aljghine](https://github.com/fahedaljghine)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 71.4% 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

Total

3

Last Release

1419d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/6369894d114a3f80e14064460fb62d1c4f713b88a4192fa3b5e9db6336f48b1c?d=identicon)[fahedaljghine](/maintainers/fahedaljghine)

---

Top Contributors

[![fahedtms](https://avatars.githubusercontent.com/u/103887694?v=4)](https://github.com/fahedtms "fahedtms (5 commits)")[![fahedaljghine](https://avatars.githubusercontent.com/u/12656813?v=4)](https://github.com/fahedaljghine "fahedaljghine (2 commits)")

---

Tags

laravelnotes

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/fahedaljghine-laravel-model-note/health.svg)

```
[![Health](https://phpackages.com/badges/fahedaljghine-laravel-model-note/health.svg)](https://phpackages.com/packages/fahedaljghine-laravel-model-note)
```

###  Alternatives

[slowlyo/owl-admin

基于 laravel、amis 开发的后台框架~

61214.2k26](/packages/slowlyo-owl-admin)[highsolutions/eloquent-sequence

A Laravel package for easy creation and management sequence support for Eloquent models with elastic configuration.

121130.3k](/packages/highsolutions-eloquent-sequence)[glhd/linen

21135.6k](/packages/glhd-linen)

PHPackages © 2026

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