PHPackages                             indy2kro/laravel-validate-models - 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. indy2kro/laravel-validate-models

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

indy2kro/laravel-validate-models
================================

Validate Eloquent models against the database schema (columns, casts, fillables, relations).

0.1.0(4mo ago)071MITPHPPHP ^8.3CI passing

Since Sep 12Pushed 1w ago1 watchersCompare

[ Source](https://github.com/indy2kro/laravel-validate-models)[ Packagist](https://packagist.org/packages/indy2kro/laravel-validate-models)[ RSS](/packages/indy2kro-laravel-validate-models/feed)WikiDiscussions main Synced today

READMEChangelog (5)Dependencies (11)Versions (10)Used By (0)

Introduction
------------

[](#introduction)

Validate your Eloquent models against the database schema. Checks columns, casts, fillable fields, and relations — catch mismatches early in CI before they break production.

✨ Features
----------

[](#-features)

- 🔍 Scans all models in app/Models (configurable paths/namespaces)
- ✅ Validates:
    - Table existence
    - Column type vs. model cast (including enums + custom casters)
    - Fillable fields vs. table columns
    - Relations resolve without error
- ⚙️ Configurable via config/validate-models.php
- 📦 Works with Laravel 10+ / PHP 8.1+
- 🧪 Fully tested with Orchestra Testbench
- 🔧 Ships with CI tooling (PHP-CS-Fixer, PHPStan, Rector, PHPUnit)

📦 Installation
--------------

[](#-installation)

```
composer require indy2kro/laravel-validate-models --dev

```

Publish the config (optional):

```
php artisan vendor:publish --tag=validate-models-config

```

⚙️ Configuration
----------------

[](#️-configuration)

`config/validate-models.php`:

```
return [
    'models_paths' => [base_path('app/Models')],
    'models_namespaces' => ['App\\Models'],
    'connection' => null,

    'checks' => [
        'columns'   => true,
        'casts'     => true,
        'fillable'  => true,
        'relations' => true,
        'annotations'=> true,
    ],

    'annotations' => [
        'columns_only' => true, // only check @property names that exist as columns
        'check_casts'  => true, // also compare annotation types vs model casts
        'check_nullability' => true, // enable/disable nullable enforcement
        'ignore'       => [     // names to ignore
        ],
        'aliases'      => [     // map short names used in @property tags to FQCNs
        ],
    ],

    'ignore' => [
        'casts'     => [],
        'fillable'  => [],
        'columns'   => [],
        'relations' => [],
    ],

    'fail_on_warnings' => true,

    'type_map' => [
        '*' => [
            'integer'  => ['int','integer','bigint','smallint','tinyint'],
            'string'   => ['string','varchar','char','text','enum','set'],
            'boolean'  => ['bool','boolean','tinyint'],
            'float'    => ['float','double','decimal'],
            'decimal'  => ['decimal','numeric'],
            'datetime' => ['datetime','timestamp'],
            'json'     => ['json','jsonb','array'],
            'array'    => ['json','jsonb','array'],
        ],
    ],
];

```

🚀 Usage
-------

[](#-usage)

Run the validation:

```
php artisan validate:models

```

Options:

```
Option	Description
--path	Override model paths (default: app/Models)
--namespace	Override model namespaces (default: App\\Models)
--connection	Use a specific DB connection
--no-columns	Skip column checks
--no-casts	Skip cast checks
--no-fillable	Skip fillable checks
--no-relations	Skip relation checks
--no-fail	Always exit 0, even with warnings

```

🧪 Testing locally
-----------------

[](#-testing-locally)

```
composer install
composer cs         # lint (php-cs-fixer dry-run)
composer cs:fix     # auto-fix style
composer stan       # static analysis (PHPStan)
composer rector     # preview Rector refactors
composer rector:fix # apply Rector refactors
composer test       # run PHPUnit
composer test:coverage

```

###  Health Score

40

—

FairBetter than 86% of packages

Maintenance88

Actively maintained with recent releases

Popularity8

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity47

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 75% 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 ~37 days

Total

5

Last Release

145d ago

PHP version history (2 changes)0.0.1PHP ^8.1

0.1.0PHP ^8.3

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1812715?v=4)[Cristi Radu](/maintainers/indy2kro)[@indy2kro](https://github.com/indy2kro)

---

Top Contributors

[![indy2kro](https://avatars.githubusercontent.com/u/1812715?v=4)](https://github.com/indy2kro "indy2kro (27 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (8 commits)")[![tc-cristian-radu](https://avatars.githubusercontent.com/u/228442392?v=4)](https://github.com/tc-cristian-radu "tc-cristian-radu (1 commits)")

---

Tags

laravelschemavalidationeloquentmodelsrelationscasts

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan, Rector

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/indy2kro-laravel-validate-models/health.svg)

```
[![Health](https://phpackages.com/badges/indy2kro-laravel-validate-models/health.svg)](https://phpackages.com/packages/indy2kro-laravel-validate-models)
```

###  Alternatives

[laravel/ai

The official AI SDK for Laravel.

1.0k3.2M194](/packages/laravel-ai)[spatie/laravel-medialibrary

Associate files with Eloquent models

6.1k43.2M631](/packages/spatie-laravel-medialibrary)[illuminate/queue

The Illuminate Queue package.

21332.6M1.6k](/packages/illuminate-queue)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9762.4M131](/packages/roots-acorn)[erag/laravel-lang-sync-inertia

A powerful Laravel package for syncing and managing language translations across backend and Inertia.js (Vue/React/Svelte) frontends, offering effortless localization, auto-sync features, and smooth multi-language support for modern Laravel applications.

4925.3k](/packages/erag-laravel-lang-sync-inertia)[itpathsolutions/dbstan

Database Standardization and Analysis Tool for Laravel

492.8k](/packages/itpathsolutions-dbstan)

PHPackages © 2026

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