PHPackages                             laranail/database-tools - 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. laranail/database-tools

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

laranail/database-tools
=======================

Independent Laravel database utilities — model traits (UUID/NanoID/ULID, audit log, soft-deletes-with-undo, JSON accessors), casts (money, datetime), schema macros, backup/restore, connection &amp; table inspection, and cursor pagination.

v0.1.0(yesterday)00MITPHPPHP ^8.3 || ^8.4 || ^8.5CI passing

Since Jun 18Pushed yesterdayCompare

[ Source](https://github.com/laranail/database-tools)[ Packagist](https://packagist.org/packages/laranail/database-tools)[ Docs](https://opensource.simtabi.com/database-tools/)[ RSS](/packages/laranail-database-tools/feed)WikiDiscussions main Synced today

READMEChangelog (1)Dependencies (15)Versions (2)Used By (0)

laranail/database-tools
=======================

[](#laranaildatabase-tools)

[![Latest version on Packagist](https://camo.githubusercontent.com/f2a6808495e933d6a2ae78af7249051ca97e6b8096e74e092cb8c907edd7e6a6/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6c6172616e61696c2f64617461626173652d746f6f6c732e737667)](https://packagist.org/packages/laranail/database-tools)[![Tests](https://github.com/laranail/database-tools/actions/workflows/tests.yml/badge.svg)](https://github.com/laranail/database-tools/actions/workflows/tests.yml)[![Static analysis](https://github.com/laranail/database-tools/actions/workflows/static-analysis.yml/badge.svg)](https://github.com/laranail/database-tools/actions/workflows/static-analysis.yml)[![License: MIT](https://camo.githubusercontent.com/7013272bd27ece47364536a221edb554cd69683b68a46fc0ee96881174c4214c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e737667)](LICENSE)

> Independent, framework-agnostic database utilities for Laravel.

Model traits (UUID, NanoID, ULID, JSON column accessors), schema macros (`auditColumns()`, `softDeletesWithUndo()`), observer base classes — designed to be useful in any Laravel app. This package is genuinely **independent**: it depends only on `illuminate/*` plus a few small utility libraries (`ramsey/uuid`, `symfony/uid`, `spatie/laravel-sluggable`, and `brick/money` for the `CastMoney`cast), and has **no dependency** on [`laranail/package-tools`](https://github.com/laranail/package-tools)or any other Laranail package. Seeding lives in `package-tools` and the seed console formatter in `console-tools` — neither belongs here.

Targets
-------

[](#targets)

- PHP `^8.3 || ^8.4 || ^8.5`
- Laravel `^13.0` — depends only on `illuminate/database` + `illuminate/support`
- Pest `^3.0`, Testbench `^11.0`
- CI matrix: in-memory SQLite + optional MySQL/Postgres legs

Install
-------

[](#install)

```
composer require laranail/database-tools
```

`DatabaseToolsServiceProvider` is auto-discovered and registers the schema macros at boot.

Quick examples
--------------

[](#quick-examples)

### UUID / NanoID / ULID model identifiers

[](#uuid--nanoid--ulid-model-identifiers)

```
use Illuminate\Database\Eloquent\Model;
use Simtabi\Laranail\DatabaseTools\Concerns\HasUuid;

class Order extends Model
{
    use HasUuid;
    // Auto-sets a v4 UUID on the `uuid` column at creating-time.
    // Override uuidColumn() to use a different column.
}
```

`HasUlid` and `HasNanoid` follow the same pattern. ULIDs are lexicographically sortable by creation time; NanoIDs are 21-char URL-safe by default.

### Audit columns + observer

[](#audit-columns--observer)

```
// Migration:
Schema::create('orders', function (Blueprint $t) {
    $t->id();
    $t->string('name');
    $t->auditColumns();           // adds created_by, updated_by, deleted_by
    $t->softDeletesWithUndo();    // adds deleted_at + restored_at
    $t->timestamps();
});

// Model:
use Simtabi\Laranail\DatabaseTools\Observers\AuditObserver;

class Order extends Model
{
    protected static function booted(): void
    {
        static::observe(AuditObserver::class);
    }
}
```

The observer stamps the authenticated user's ID into the audit columns on create/update/delete; override `userIdentifier()` if your FK isn't the user's primary key.

### JSON column accessors

[](#json-column-accessors)

```
use Simtabi\Laranail\DatabaseTools\Concerns\HasJsonColumnAccessors;

class Order extends Model
{
    use HasJsonColumnAccessors;

    protected array $jsonColumns = ['metadata', 'snapshot'];
}

$order->metadata = ['shipped_via' => 'fedex'];   // auto-encoded on save
$order->save();
$order->metadata['shipped_via'];                 // 'fedex' — auto-decoded on read
```

Skips columns already in `$casts` to avoid double-cast.

Local development
-----------------

[](#local-development)

```
bash .scripts/init.sh
composer test                 # vendor/bin/pest
composer lint                 # pint + phpstan + rector --dry-run
composer audit                # composer audit (security advisories)
```

Documentation
-------------

[](#documentation)

Hosted at [`opensource.simtabi.com/database-tools/docs/`](https://opensource.simtabi.com/database-tools/docs/)(product page: [`opensource.simtabi.com/database-tools/`](https://opensource.simtabi.com/database-tools/)). The same pages live under [`docs/`](docs/):

**Guides**

- [Installation](docs/installation.md) — Composer install, auto-discovery, the `DatabaseTools` facade, targets
- [Configuration](docs/configuration.md) — publishing `config/database-tools.php` + the history migration; every config key
- [Architecture](docs/architecture.md) — how the facade, schema services, and backup drivers fit together; the independence invariant

**Tools &amp; features**

- [Facade](docs/tools/facade.md) — every `DatabaseTools` static method, with examples
- [Connection testing](docs/tools/connection-testing.md) — `DatabaseConnectionTester`: test, driver, version, database name
- [Schema inspection](docs/tools/schema-inspection.md) — `DatabaseSchemaInspector`: tables, columns, counts
- [Table verification](docs/tools/table-verification.md) — `DatabaseTableVerifier`: verify, detailed report, Laravel tables
- [Backup &amp; restore](docs/tools/backup-restore.md) — `BackupManager`, per-driver backups, driver-aware restore, dump import
- [Traits](docs/tools/traits.md) — model identifier &amp; behavior traits under `Concerns/`
- [Casts](docs/tools/casts.md) — `CastMoney` (brick/money) and `CastDatetime`
- [Schema macros](docs/tools/macros.md) — `auditColumns()`, `softDeletesWithUndo()`, `configuredMorphs()`, `softDeleteHistory()`, `BlueprintMacros`
- [Audit observer](docs/tools/observers.md) — `AuditObserver` + `HasAuditObserver`: stamping created/updated/deleted by
- [Soft-delete restore history](docs/tools/soft-deletes.md) — `HasSoftDeletesWithUndo` trait + history table
- [Eager-load helpers](docs/tools/eager-loading.md) — `LoadsAggregatesIfMissing`: load-if-missing for counts &amp; aggregates
- [Cursor pagination](docs/tools/pagination.md) — `CursorPage` DTO over native `cursorPaginate()`
- [Events](docs/tools/events.md) — `DatabaseEvents` + `BaseEvent`
- [BaseModel](docs/tools/base-model.md) — the optional base Eloquent model

**Examples**

- [Runnable examples](docs/examples/) — `Order.php` + `OrderMigration.php` demonstrating the identifier traits, audit columns, soft-deletes-with-undo, and JSON accessors together
- Changelog: [CHANGELOG.md](CHANGELOG.md)

Sister packages
---------------

[](#sister-packages)

- [`laranail/package-tools`](https://github.com/laranail/package-tools) — runtime base library for building Laravel packages.
- [`laranail/package-scaffolder`](https://github.com/laranail/package-scaffolder) — generator that scaffolds new packages.
- [`laranail/laranail`](https://github.com/laranail/laranail) — Simtabi's Laravel utility toolbox.

License
-------

[](#license)

MIT. See [LICENSE](LICENSE).

###  Health Score

38

—

LowBetter than 83% of packages

Maintenance100

Actively maintained with recent releases

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity40

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

Unknown

Total

1

Last Release

1d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/3108393?v=4)[Simtabi](/maintainers/simtabi)[@simtabi](https://github.com/simtabi)

---

Top Contributors

[![imanimanyara](https://avatars.githubusercontent.com/u/19682005?v=4)](https://github.com/imanimanyara "imanimanyara (14 commits)")

---

Tags

laraveldatabasebackupuuidulidAuditsoft deletesnanoidlaranailschema-macros

###  Code Quality

TestsPest

Static AnalysisPHPStan, Rector

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/laranail-database-tools/health.svg)

```
[![Health](https://phpackages.com/badges/laranail-database-tools/health.svg)](https://phpackages.com/packages/laranail-database-tools)
```

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3325.1M337](/packages/psalm-plugin-laravel)[yajra/laravel-oci8

Oracle DB driver for Laravel via OCI8

8723.1M23](/packages/yajra-laravel-oci8)[glushkovds/phpclickhouse-laravel

Adapter of the most popular library https://github.com/smi2/phpClickHouse to Laravel

2051.4M2](/packages/glushkovds-phpclickhouse-laravel)[laravelcm/laravel-subscriptions

Laravel Subscriptions is a flexible plans and subscription management system for Laravel, with the required tools to run your SAAS like services efficiently. It's simple architecture, accompanied by powerful underlying to afford solid platform for your business.

24364.4k4](/packages/laravelcm-laravel-subscriptions)[rcsofttech/audit-trail-bundle

Enterprise-grade, high-performance Symfony audit trail bundle. Automatically track Doctrine entity changes with split-phase architecture, multiple transports (HTTP, Queue, Doctrine), and sensitive data masking.

1155.2k](/packages/rcsofttech-audit-trail-bundle)[masterix21/laravel-licensing

Laravel licensing package with polymorphic assignment to any model, activation keys, expirations/renewals, and seat control via LicenseUsage. Supports offline verification with public-key–signed tokens, a CLI to generate/rotate/revoke keys, and an extensible architecture via config and contracts.

1432.1k4](/packages/masterix21-laravel-licensing)

PHPackages © 2026

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