PHPackages                             centrex/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. [Database &amp; ORM](/categories/database)
4. /
5. centrex/laravel-model-note

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

centrex/laravel-model-note
==========================

This package add note to eloquent model

v1.3.3(7mo ago)12.4k[4 PRs](https://github.com/centrex/laravel-model-note/pulls)MITPHPPHP ^8.2|^8.3|^8.4CI passing

Since Jun 2Pushed 1mo agoCompare

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

READMEChangelogDependencies (14)Versions (19)Used By (0)

This package add note to eloquent model
=======================================

[](#this-package-add-note-to-eloquent-model)

[![Latest Version on Packagist](https://camo.githubusercontent.com/0a926f96b99757697533ad9e05483c9beee2911e83eaf903ab305da047a458ef/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f63656e747265782f6c61726176656c2d6d6f64656c2d6e6f74652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/centrex/laravel-model-note)[![GitHub Tests Action Status](https://camo.githubusercontent.com/6d800d2123f405741f192f81b3c7f388c6c9adac31d6fc9bdf059951c4124204/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f63656e747265782f6c61726176656c2d6d6f64656c2d6e6f74652f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/centrex/laravel-model-note/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/629ed617b0326f522797f7a812f1f5a82480ea3dd0e48876294cc7c729928d87/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f63656e747265782f6c61726176656c2d6d6f64656c2d6e6f74652f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/centrex/laravel-model-note/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/7fe74e624f61c345235ea512933f2b8af307c9d4d9a5f8cbf8694f3c253215dc/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f63656e747265782f6c61726176656c2d6d6f64656c2d6e6f74653f7374796c653d666c61742d737175617265)](https://packagist.org/packages/centrex/laravel-model-note)

This is where your description should go. Limit it to a paragraph or two. Consider adding a small example.

Contents
--------

[](#contents)

- [Installation](#installation)
- [Usage](#usage)
- [Testing](#testing)
- [Changelog](#changelog)
- [Contributing](#contributing)
- [Credits](#credits)
- [License](#license)

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

[](#installation)

You can install the package via composer:

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

You can publish the config file with:

```
php artisan vendor:publish --tag="laravel-model-note-config"
```

You can publish and run the migrations with:

```
php artisan vendor:publish --tag="laravel-model-note-migrations"
php artisan migrate
```

Usage
-----

[](#usage)

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

```
use Centrex\LaravelModelNote\HasNotes;

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

### Add a new note

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

You can add a new note like this:

```
// Add a public note
$model->addNote('whatever you like');
// or with tag
$user->addNote('Customer called about billing issue', false, 'support');
```

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 `Centrex\LaravelModelNote\ModelNote`

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

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");
```

```
// Get all private notes
$privateNotes = ModelNote::private()->get();

// Get public notes with specific tag
$publicTaggedNotes = ModelNote::public()->withTag('feedback')->get();

// Get time ago for a note
$note = ModelNote::first();
echo $note->time_ago; // "2 hours ago"
```

### 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();
```

### Error handling

[](#error-handling)

```
try {
    // Validate model class
    if (!is_subclass_of($modelClass, ModelNote::class)) {
        throw InvalidNoteModel::create($modelClass);
    }
} catch (InvalidNoteModel $e) {
    // Access additional context
    $context = $e->context();

    // Log full error details
    logger()->error($e->getMessage(), $context);

    // Handle exception appropriately
}
```

Testing
-------

[](#testing)

🧹 Keep a modern codebase with **Pint**:

```
composer lint
```

✅ Run refactors using **Rector**

```
composer refacto
```

⚗️ Run static analysis using **PHPStan**:

```
composer test:types
```

✅ Run unit tests using **PEST**

```
composer test:unit
```

🚀 Run the entire test suite:

```
composer test
```

Changelog
---------

[](#changelog)

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

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

[](#contributing)

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

Credits
-------

[](#credits)

- [rochi88](https://github.com/centrex)
- [laravel-model-note](https://github.com/tmsllc/laravel-model-note)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

###  Health Score

47

—

FairBetter than 94% of packages

Maintenance78

Regular maintenance activity

Popularity19

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor1

Top contributor holds 66% 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 ~38 days

Total

14

Last Release

221d ago

Major Versions

v0.0.2 → v1.0.02024-06-02

PHP version history (2 changes)v0.0.1PHP ^8.1|^8.2

v1.1.0PHP ^8.2|^8.3|^8.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/3b62fd49922fd1bf7d55b94cc82ebc9f359af7f343b246a7e3a2642779c0b4e7?d=identicon)[rochi88](/maintainers/rochi88)

---

Top Contributors

[![rochi88](https://avatars.githubusercontent.com/u/29769944?v=4)](https://github.com/rochi88 "rochi88 (33 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (10 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (7 commits)")

---

Tags

laravelcentrexlaravel-model-note

###  Code Quality

TestsPest

Static AnalysisPHPStan, Rector

Code StyleLaravel Pint

### Embed Badge

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

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

###  Alternatives

[tucker-eric/eloquentfilter

An Eloquent way to filter Eloquent Models

1.8k4.8M26](/packages/tucker-eric-eloquentfilter)[watson/validating

Eloquent model validating trait.

9723.3M47](/packages/watson-validating)[yajra/laravel-oci8

Oracle DB driver for Laravel via OCI8

8703.0M17](/packages/yajra-laravel-oci8)[cybercog/laravel-love

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

1.2k302.7k1](/packages/cybercog-laravel-love)[cviebrock/eloquent-taggable

Easy ability to tag your Eloquent models in Laravel.

567694.8k3](/packages/cviebrock-eloquent-taggable)[clickbar/laravel-magellan

This package provides functionality for working with the postgis extension in Laravel.

423715.4k1](/packages/clickbar-laravel-magellan)

PHPackages © 2026

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