PHPackages                             lesichkovm/laravel-advanced-model - 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. lesichkovm/laravel-advanced-model

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

lesichkovm/laravel-advanced-model
=================================

Advanced model class for Laravel

v1.9.0(4y ago)42.7k22proprietaryPHP

Since Dec 9Pushed 4y ago1 watchersCompare

[ Source](https://github.com/lesichkovm/laravel-advanced-model)[ Packagist](https://packagist.org/packages/lesichkovm/laravel-advanced-model)[ Docs](http://github.com/lesichkovm/laravel-advanced-model)[ RSS](/packages/lesichkovm-laravel-advanced-model/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (9)Dependencies (1)Versions (10)Used By (2)

Laravel Advanced Model
======================

[](#laravel-advanced-model)

An advanced model for Laravel. Has out-of-the-box support for SnakeCase (Laravel's default), as well as for CamelCase field names, and enhanced primary key support - human friendly date based unique IDs, and UUIDs.

Background
----------

[](#background)

1. Snake case (snake\_case) advanced model. This is the default Laravel's model. This model uses the foillowing fields:

```
id - Identity field
created_at - When was the record created
updated_at - When was the record last modified
deleted_at - When was the record deleted (soft delete)

```

2. Camel case (CamelCase). Camel case is more readable and a bit shorter than snake case (more at [https://en.wikipedia.org/wiki/Camel\_case](https://en.wikipedia.org/wiki/Camel_case)). This model changes the default Laravel names to:

```
Id - Identity field
CreatedAt - When was the record created
UpdatedAt - When was the record last modified
DeletedAt - When was the record deleted (soft delete)

```

3. The default Laravel model uses only incremental primary keys. Though it works for basic use cases, this causes extra effort for deduping records on larger systems. A much better option is to use unique IDs. This class supports UUIDs, as well as more human friendly unique unique IDs (HUID).

Human-friendly Unique IDs (HUIDs)
---------------------------------

[](#human-friendly-unique-ids-huids)

The Human-friendly unique IDs (HUIDs) are numeric strings consisting of the date and time with a random variable length postfix. The usual length is 20, but can be increased, if more uniqueness is required. Example: 20170715081335698999

The HUIDs are less unique than UUIDs, but have more value for everyday usage:

- They do provide enough information to uniquely identify a record in 99.99% of the user cases.
- Being date based provides answer when the record was created.
- Can be ordered in ascending/descending order as they are numeric
- Unlike UUIDs are easy for humans to read, especially when separated with dashes
- Can be further transferred to other numeric bases

```
{
  "human-readable-form" : "20170715-081335-698999",
  "base10" : "20170715081335698999",
  "base16" : "117ECC67F58A0F637",
  "base32" : "MDC4D43APZUIJ",
  "base36" : "498WXQXN91ET3",
  "base62" : "O225WNTn5DL",
  "base64" : "HVindzOeFOt",
  "base75" : "3hl}S8,t*rO",
  "base100" : "kh7f8dz/Y8",
  "crockford32" : "HFV66FXCA1XHQ"
}
```

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

[](#installation)

- Using composer

```
composer require lesichkovm/laravel-advanced-model
```

Usage
-----

[](#usage)

Extend your model classes

- Using AdvancedSnakeCaseModel

```
class MyModel extends \AdvancedSnakeCaseModel {
    private $useUniqueId = true;
}
```

- Using AdvancedCamelCaseModel

```
class MyModel extends \AdvancedCamelCaseModel {
    private $useUniqueId = true;
}
```

- Human-friendly Unique ID (HUID)

```
class MyModel extends \AdvancedSnakeCaseModel {
    private $useUniqueId = true;
}
```

- Universally Unique ID (UUID)

```
class MyModel extends \AdvancedSnakeCaseModel {
    private $useUuid = true;
}
```

- Autoincrements

```
class MyModel extends \AdvancedSnakeCaseModel {
    private $incrementing = true;
}
```

Create Model and Retrieve ID
----------------------------

[](#create-model-and-retrieve-id)

- Create snake case model instance and retrieve ID

```
$instance = new MyModel;
$instance->save();

echo $instance->id;
```

- Create new camel case model instance and retrieve ID

```
$instance = new MyModel;
$instance->save();

echo $instance->Id;
```

Additional Methods
------------------

[](#additional-methods)

- chunks($perChunk)
- getConnName
- getTableName
- trash
- untrash

###  Health Score

35

—

LowBetter than 80% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity24

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity69

Established project with proven stability

 Bus Factor1

Top contributor holds 94.6% 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 ~200 days

Recently: every ~238 days

Total

9

Last Release

1470d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/2d5e7549502cd22df16f7dddbc83eb579b3995874be024d64f7f0f7dab2e1e8d?d=identicon)[lesichkovm](/maintainers/lesichkovm)

---

Top Contributors

[![lesichkovm](https://avatars.githubusercontent.com/u/7744963?v=4)](https://github.com/lesichkovm "lesichkovm (35 commits)")[![Sinevia](https://avatars.githubusercontent.com/u/3450815?v=4)](https://github.com/Sinevia "Sinevia (2 commits)")

---

Tags

phplaravelmodeladvancedlesichkov

### Embed Badge

![Health badge](/badges/lesichkovm-laravel-advanced-model/health.svg)

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

###  Alternatives

[spiritix/lada-cache

A Redis based, automated and scalable database caching layer for Laravel

591444.8k2](/packages/spiritix-lada-cache)[dyrynda/laravel-model-uuid

This package allows you to easily work with UUIDs in your Laravel models.

4802.8M8](/packages/dyrynda-laravel-model-uuid)[glushkovds/phpclickhouse-laravel

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

2031.2M2](/packages/glushkovds-phpclickhouse-laravel)[sebastiaanluca/laravel-boolean-dates

Automatically convert Eloquent model boolean attributes to dates (and back).

40111.7k1](/packages/sebastiaanluca-laravel-boolean-dates)[ymigval/laravel-model-cache

Laravel package for caching Eloquent model queries

7642.2k3](/packages/ymigval-laravel-model-cache)[kiwilan/typescriptable-laravel

PHP package for Laravel to type Eloquent models, routes, Spatie Settings with autogenerated TypeScript. If you want to use some helpers with Inertia, you can install associated NPM package.

3920.9k](/packages/kiwilan-typescriptable-laravel)

PHPackages © 2026

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