PHPackages                             webgefaehrten/laravel-auto-notes - 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. webgefaehrten/laravel-auto-notes

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

webgefaehrten/laravel-auto-notes
================================

Polymorphic notes package for Laravel models with owner support, field diffs, retention, and multi-language support.

v0.1.5(8mo ago)10MITPHPPHP ^8.2|^8.3

Since Sep 10Pushed 8mo agoCompare

[ Source](https://github.com/webgefaehrten/laravel-auto-notes)[ Packagist](https://packagist.org/packages/webgefaehrten/laravel-auto-notes)[ RSS](/packages/webgefaehrten-laravel-auto-notes/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (3)Versions (16)Used By (0)

Laravel Auto Notes
==================

[](#laravel-auto-notes)

Polymorphe Notizen für Laravel-Modelle mit optionalem Owner (Aggregation), automatischen Diffs (Feldänderungen), In-Class-Konfiguration, Retention/Pruning, optionalem Owner-Index und Mehrsprachigkeit (DE/EN).

---

🇩🇪 Deutsch
----------

[](#-deutsch)

### ✨ Features

[](#-features)

- Automatische Notizen bei `created`, `updated`, `deleted`
- Feld-Diffs: von `X` → `Y`
- Owner/Aggregation: z. B. Kunde ↔ Baustellen ↔ Kontakte
- In-Class-Konfiguration (kein zentrales Config-File nötig)
- Manuelles Hinzufügen von Notizen (`addNote()`)
- Observer pro Model deaktivierbar oder austauschbar
- Retention &amp; Archivierung (alte Notizen löschen oder verschieben)
- Optionaler Owner-Index für schnelle Abfragen
- Mehrsprachigkeit (DE/EN) mit Publish-Option

### 🚀 Installation

[](#-installation)

```
composer require webgefaehrten/laravel-auto-notes
```

Publizieren:

```
php artisan vendor:publish --provider="Webgefaehrten\AutoNotes\AutoNotesServiceProvider" --tag=auto-notes-config
php artisan vendor:publish --provider="Webgefaehrten\AutoNotes\AutoNotesServiceProvider" --tag=auto-notes-migrations
php artisan vendor:publish --provider="Webgefaehrten\AutoNotes\AutoNotesServiceProvider" --tag=auto-notes-lang
```

Migrationen ausführen:

```
php artisan migrate
```

### 🛠 Verwendung

[](#-verwendung)

**Subject-Model (z. B. `CustomerSite`):**

```
use Webgefaehrten\AutoNotes\Traits\HasNotes;
use Webgefaehrten\AutoNotes\Contracts\ProvidesAutoNotesConfig;
use Illuminate\Database\Eloquent\Model;

class CustomerSite extends Model implements ProvidesAutoNotesConfig
{
    use HasNotes;

    protected $fillable = ['customer_id','name','street','zip','city'];

    public function customer() { return $this->belongsTo(Customer::class); }

    // In-Class Konfiguration
    public function autoNoteContext(): ?string { return 'site'; }
    public function autoNoteLabels(): array { return ['name'=>'Name','city'=>'Ort']; }
    public function autoNoteInclude(): array { return ['name','city','zip','street']; }

    // Variante 1: direkte Relation (funktioniert, wenn Relation verfügbar ist)
    public function autoNoteOwner(): ?Model { return $this->customer; }

    // Variante 2: robuste Variante (nur Klasse zurückgeben, FK wird automatisch erkannt)
    public function autoNoteOwner(): Model|string|array|\Closure|null
    {
        return \App\Models\Customer::class;
    }

    public function autoNoteOwnerKey(): ?string
    {
        return 'customer_id'; // optional
    }

    public function autoNoteDisplayName(): ?string { return $this->name; }
}
```

**Owner-Model (z. B. `Customer`):**

```
use Webgefaehrten\AutoNotes\Traits\AggregatesNotes;

class Customer extends Model
{
    use AggregatesNotes; // ->allNotes()
}
```

**Manuell Notiz anlegen:**

```
$site->addNote(
    title: 'Adresse geändert',
    body:  'Von A-Straße nach B-Straße',
    context: 'site',
    owner:  $site->customer
);
```

**Alle Notizen abrufen:**

```
$notes = $customer->allNotes; // alle Notizen des Customers
$notes = $site->notes;        // nur Notizen der Site
```

### ⚙️ Retention / Archivierung

[](#️-retention--archivierung)

Konfiguration in `config/auto-notes.php`:

```
'retention_days'      => 730,
'retention_overrides' => [
    'order' => 1825, // 5 Jahre für Aufträge
],
'archive_to_table'    => 'notes_archive',
```

Prune-Command:

```
php artisan auto-notes:prune
```

### 🌍 Mehrsprachigkeit

[](#-mehrsprachigkeit)

```
php artisan vendor:publish --tag=auto-notes-lang
```

Verfügbare Sprachen: `de`, `en`.

---

🇬🇧 English
----------

[](#-english)

### ✨ Features

[](#-features-1)

- Automatic notes on `created`, `updated`, `deleted`
- Field diffs: from `X` → `Y`
- Owner/Aggregation: e.g. Customer ↔ Sites ↔ Contacts
- In-class configuration (no central config file required)
- Add notes manually (`addNote()`)
- Observer per model can be disabled or replaced
- Retention &amp; pruning (delete/archive old notes)
- Optional owner index for fast queries
- Multi-language (EN/DE) with publish option

### 🚀 Installation

[](#-installation-1)

```
composer require webgefaehrten/laravel-auto-notes
```

Publish:

```
php artisan vendor:publish --provider="Webgefaehrten\AutoNotes\AutoNotesServiceProvider" --tag=auto-notes-config
php artisan vendor:publish --provider="Webgefaehrten\AutoNotes\AutoNotesServiceProvider" --tag=auto-notes-migrations
php artisan vendor:publish --provider="Webgefaehrten\AutoNotes\AutoNotesServiceProvider" --tag=auto-notes-lang
```

Run migrations:

```
php artisan migrate
```

### 🛠 Usage

[](#-usage)

**Subject model (e.g. `CustomerSite`):**

```
use Webgefaehrten\AutoNotes\Traits\HasNotes;
use Webgefaehrten\AutoNotes\Contracts\ProvidesAutoNotesConfig;
use Illuminate\Database\Eloquent\Model;

class CustomerSite extends Model implements ProvidesAutoNotesConfig
{
    use HasNotes;

    protected $fillable = ['customer_id','name','street','zip','city'];

    public function customer() { return $this->belongsTo(Customer::class); }

    public function autoNoteContext(): ?string { return 'site'; }
    public function autoNoteLabels(): array { return ['name'=>'Name','city'=>'City']; }
    public function autoNoteInclude(): array { return ['name','city','zip','street']; }

    // Variant 1: direct relation
    public function autoNoteOwner(): ?Model { return $this->customer; }

    // Variant 2: more robust (only return class, FK auto-resolved)
    public function autoNoteOwner(): Model|string|array|\Closure|null
    {
        return \App\Models\Customer::class;
    }

    public function autoNoteOwnerKey(): ?string
    {
        return 'customer_id'; // optional
    }

    public function autoNoteDisplayName(): ?string { return $this->name; }
}
```

**Owner model (e.g. `Customer`):**

```
use Webgefaehrten\AutoNotes\Traits\AggregatesNotes;

class Customer extends Model
{
    use AggregatesNotes; // ->allNotes()
}
```

**Add note manually:**

```
$site->addNote(
    title: 'Address changed',
    body:  'From A-Street to B-Street',
    context: 'site',
    owner:  $site->customer
);
```

**Fetch notes:**

```
$notes = $customer->allNotes; // all notes of the customer
$notes = $site->notes;        // only notes of the site
```

### ⚙️ Retention / Archiving

[](#️-retention--archiving)

Config in `config/auto-notes.php`:

```
'retention_days'      => 730,
'retention_overrides' => [
    'order' => 1825, // 5 years for orders
],
'archive_to_table'    => 'notes_archive',
```

Prune command:

```
php artisan auto-notes:prune
```

### 🌍 Multi-language

[](#-multi-language)

```
php artisan vendor:publish --tag=auto-notes-lang
```

Available languages: `en`, `de`.

---

ℹ️ Owner Resolution
-------------------

[](#ℹ️-owner-resolution)

- `autoNoteOwner()` may return:

    - a `Model`
    - a `class-string` (e.g. `Customer::class`)
    - an array `[Customer::class, $id]`
    - a `Closure` returning a `Model`
    - or `null`
- Optional methods:

    - `autoNoteOwnerKey()` → explicit FK name
    - `autoNoteOwnerRelation()` → explicit relation name

Default heuristics: `customer_id` → `owner_id` → `{ClassSnake}_id` → relation.

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance61

Regular maintenance activity

Popularity2

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 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 ~0 days

Total

15

Last Release

244d ago

PHP version history (3 changes)v0.0.1PHP ^8.1

v0.0.2PHP ^8.1|^8.2|^8.3

v0.0.3PHP ^8.2|^8.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/25fe00e2caf5bc826b35b80f43ea37dfe37da23c6c980fafa84c98722ccf134a?d=identicon)[TriXxer](/maintainers/TriXxer)

---

Top Contributors

[![webgefaehrten](https://avatars.githubusercontent.com/u/127493106?v=4)](https://github.com/webgefaehrten "webgefaehrten (17 commits)")

---

Tags

laravelactivityobserverhistorytimelinenotes

### Embed Badge

![Health badge](/badges/webgefaehrten-laravel-auto-notes/health.svg)

```
[![Health](https://phpackages.com/badges/webgefaehrten-laravel-auto-notes/health.svg)](https://phpackages.com/packages/webgefaehrten-laravel-auto-notes)
```

###  Alternatives

[barryvdh/laravel-ide-helper

Laravel IDE Helper, generates correct PHPDocs for all Facade classes, to improve auto-completion.

14.9k123.0M687](/packages/barryvdh-laravel-ide-helper)[owen-it/laravel-auditing

Audit changes of your Eloquent models in Laravel

3.4k33.0M95](/packages/owen-it-laravel-auditing)[spatie/laravel-enum

Laravel Enum support

3655.4M31](/packages/spatie-laravel-enum)[zonneplan/laravel-module-loader

Module loader for Laravel

24118.4k](/packages/zonneplan-laravel-module-loader)[tehwave/laravel-achievements

Simple, elegant Achievements the Laravel way

7012.8k](/packages/tehwave-laravel-achievements)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

255.2k](/packages/aedart-athenaeum)

PHPackages © 2026

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