centrex/laravel-model-note

This package add note to eloquent model
2,351 1
Install
composer require centrex/laravel-model-note
Latest Version:v1.3.3
PHP:^8.3
License:MIT
Last Updated:Aug 9, 2026
Links: GitHub  ·  Packagist
Maintainer: rochi88

Add notes to any Eloquent model

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

Attach polymorphic notes to any Eloquent model with support for tagging, privacy control, and bulk operations. Notes are stored in a model_notes table and ordered newest-first by default.

Installation

composer require centrex/laravel-model-note
php artisan vendor:publish --tag="laravel-model-note-migrations"
php artisan migrate

Usage

1. Add the trait

use Centrex\LaravelModelNote\HasNotes;

class Order extends Model
{
    use HasNotes;
}

2. Add notes

$order->addNote('Payment confirmed by finance.');

// Private note (not shown to customers)
$order->addPrivateNote('Suspicious address — flag for review.');

// Tagged note
$order->addNote('Dispatched via DHL.', tag: 'shipping');
$order->addNote('Customer called in.', isPrivate: true, tag: 'support');

3. Read notes

// Latest note content (shortcut)
echo $order->note();

// Latest note object, optionally filtered by tag
$note = $order->lastNote('shipping');
echo $note->time_ago;  // "2 hours ago"

// All notes
$order->allNotes();
$order->allNotes('support');   // filtered by tag

// Private notes only
$order->privateNotes();
$order->privateNotes('shipping');

4. Delete notes

$order->deleteNote(5);
$order->deleteNote([5, 6, 7]);
$order->deleteNoteByTag('shipping');
$order->deleteAllNotes();

5. Query scopes on ModelNote

use Centrex\LaravelModelNote\ModelNote;

ModelNote::private()->get();
ModelNote::public()->get();
ModelNote::withTag('support')->get();

ModelNote attributes

Attribute Type Description
note string Note content
tag string|null Optional category tag
is_private bool Hidden from non-admin views
user_id int|null Author (defaults to auth()->id())
time_ago string Human-readable age (diffForHumans())

Testing

composer test        # full suite
composer test:unit   # pest only
composer test:types  # phpstan
composer lint        # pint

Changelog

Please see CHANGELOG for more information on what has changed recently.

Credits

License

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

Related Packages

centrex/laravel-open-exchange-rates

This is my package laravel-open-exchange-rates

3,923 0
centrex/laravel-addresses

Manage address in laravel

3,705 0
centrex/laravel-cart

Shopping cart for Laravel with session, cookie, and database storage, Livewire c...

1,054 0
centrex/laravel-accounting

Manage accounts in laravel

4,479 3
centrex/laravel-settings

Manage settings in laravel

3,702 0