PHPackages                             marslankhalid/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. [Utility &amp; Helpers](/categories/utility)
4. /
5. marslankhalid/laravel-model-note

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

marslankhalid/laravel-model-note
================================

A package to enable assigning notes to Eloquent Models

1.0.1(1mo ago)08↓100%MITPHPPHP ^8.0|^8.1|^8.2

Since Apr 22Pushed 1mo agoCompare

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

READMEChangelog (1)Dependencies (3)Versions (3)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 \TMSLLC\ModelNotes\Note

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

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

[](#contact-me)

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

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

[](#installation)

You can install the package via composer:

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

You must publish the migration with:

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

Migrate the `notes` table:

```
php artisan migrate
```

Optionally you can publish the config-file with:

```
php artisan vendor:publish --provider="TMSLLC\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 `TMSLLC\ModelNote\Note`.
     */
    'note_model' => TMSLLC\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 TMSLLC\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 `TMSLLC\ModelNote\Note`

//or alternatively
$model->lastNote(); // returns the last instance of `TMSLLC\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.

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

[](#contributing)

You are welcome to contribute

Credits
-------

[](#credits)

This package was originally written by: [DigitalCloud](https://github.com/DigitalCloud/laravel-model-notes).

- [Transport Systems](https://github.com/tmsllc)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

###  Health Score

40

—

FairBetter than 86% of packages

Maintenance90

Actively maintained with recent releases

Popularity5

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity47

Maturing project, gaining track record

 Bus Factor2

2 contributors hold 50%+ of commits

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

48d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/61bcb202c0ad02f9032e7a58f32f30afab58e77130b94342c75c2e7a803fa4eb?d=identicon)[marslankhalid](/maintainers/marslankhalid)

---

Top Contributors

[![DevMArsalan-ctrl](https://avatars.githubusercontent.com/u/263907356?v=4)](https://github.com/DevMArsalan-ctrl "DevMArsalan-ctrl (6 commits)")[![usmantms](https://avatars.githubusercontent.com/u/124586947?v=4)](https://github.com/usmantms "usmantms (4 commits)")[![marslankhalid](https://avatars.githubusercontent.com/u/16500135?v=4)](https://github.com/marslankhalid "marslankhalid (3 commits)")[![tmsllc](https://avatars.githubusercontent.com/u/105742520?v=4)](https://github.com/tmsllc "tmsllc (1 commits)")

---

Tags

laravelnotes

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3325.1M337](/packages/psalm-plugin-laravel)[renatomarinho/laravel-page-speed

Laravel Page Speed

2.5k1.7M11](/packages/renatomarinho-laravel-page-speed)[vinkius-labs/laravel-page-speed

Laravel Page Speed

2.5k9.6k1](/packages/vinkius-labs-laravel-page-speed)[emargareten/inertia-modal

Inertia Modal is a Laravel package that lets you implement backend-driven modal dialogs for Inertia apps.

90128.1k](/packages/emargareten-inertia-modal)[linkxtr/laravel-qrcode

A clean, modern, and easy-to-use QR code generator for Laravel

3614.9k](/packages/linkxtr-laravel-qrcode)[wearepixel/laravel-cart

A cart implementation for Laravel

1355.6k](/packages/wearepixel-laravel-cart)

PHPackages © 2026

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