PHPackages                             g4t/model-studio - 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. g4t/model-studio

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

g4t/model-studio
================

Eloquent model studio for Laravel — generates models with relationships and casts from your migration files, and detects drift between your schema and existing models.

0.0.1(today)01↑2900%MITPHPPHP ^8.0

Since Jul 27Pushed todayCompare

[ Source](https://github.com/hussein4alaa/laravel-model-studio)[ Packagist](https://packagist.org/packages/g4t/model-studio)[ RSS](/packages/g4t-model-studio/feed)WikiDiscussions main Synced today

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

 [![g4t Model Studio — your migrations already know your models](art/cover.svg)](art/cover.svg)

 [![Packagist](https://camo.githubusercontent.com/f0e9180c5ab2e6ee628da614a588d714f87dc63614d8c2df86aebadb11985b41/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7061636b61676973742d6734742532466d6f64656c2d2d73747564696f2d3265636338663f7374796c653d666c61742d737175617265)](https://packagist.org/packages/g4t/model-studio) [![Laravel 8 to 13](https://camo.githubusercontent.com/6cb9cbe166ae13de21bd2f8f6efec34ad17ef66a139187fd41dbb5c4a8c8793e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c2d38253230e2869225323031332d6666326432303f7374796c653d666c61742d737175617265266c6f676f3d6c61726176656c)](https://camo.githubusercontent.com/6cb9cbe166ae13de21bd2f8f6efec34ad17ef66a139187fd41dbb5c4a8c8793e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c2d38253230e2869225323031332d6666326432303f7374796c653d666c61742d737175617265266c6f676f3d6c61726176656c) [![PHP ^8.0](https://camo.githubusercontent.com/54a1e5f49a45a94bb3bc9b3c95239441c0f84ca39b24b8917cf51c5c6c5cde0f/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d253545382e302d3737376262343f7374796c653d666c61742d737175617265266c6f676f3d706870)](https://camo.githubusercontent.com/54a1e5f49a45a94bb3bc9b3c95239441c0f84ca39b24b8917cf51c5c6c5cde0f/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d253545382e302d3737376262343f7374796c653d666c61742d737175617265266c6f676f3d706870) [![MIT](https://camo.githubusercontent.com/fb7e27999c1c702085a6a2e0378d9c6fbb085370a17ae8b61b6fef98a65a5e1f/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d3265636338663f7374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/fb7e27999c1c702085a6a2e0378d9c6fbb085370a17ae8b61b6fef98a65a5e1f/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d3265636338663f7374796c653d666c61742d737175617265)

g4t Model Studio
================

[](#g4t-model-studio)

Generate Eloquent models from your **migration files** — and keep them in sync forever.

Model Studio reads your schema the same way [g4t/schema-designer](https://packagist.org/packages/g4t/schema-designer) does: by replaying migrations against a capturing schema builder (zero SQL, zero database introspection). It then compares that schema against the models in `app/Models` and gives you a studio UI where every table is either **missing** (one click generates a complete model), **drifted** (you get a precise report with paste-ready fixes), or **synced**.

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

[](#installation)

```
composer require g4t/model-studio
```

The service provider is auto-discovered. Open the studio at:

```
http://your-app.test/model-studio

```

What it generates
-----------------

[](#what-it-generates)

For a table like `orders`, Model Studio produces a complete model:

- `$fillable` from real columns (PK, timestamps, soft-delete and token columns excluded)
- `$casts` inferred from column types — `boolean`, `array` for json, `datetime`, `date`, `decimal:N`, `float`
- `$table`, `$primaryKey`, `$keyType`/`$incrementing` (UUID keys detected), `$timestamps = false` when absent
- `SoftDeletes` when the table has `deleted_at`
- **Relationships inferred from foreign keys**:
    - FK on the table → `belongsTo`
    - FK elsewhere pointing here → `hasMany` (or `hasOne` when the FK is unique)
    - pivot tables (two FKs, no payload) → `belongsToMany` on both sides
    - `{x}_id` + `{x}_type` pairs → `morphTo`

Drift reports
-------------

[](#drift-reports)

For tables that already have a model, Model Studio never touches your file. Instead it reports:

- columns missing from `$fillable` (models using the `$guarded = []` style are respected and skipped)
- stale `$fillable` entries that no longer exist in the schema
- suggested `$casts` you haven't declared
- relation methods that should exist — each one as a paste-ready snippet with a fully-qualified return type

Compatibility
-------------

[](#compatibility)

**Laravel**8.x, 9.x, 10.x, 11.x, 12.x, 13.x**PHP**^8.0**Databases**Driver-agnostic — the schema comes from Blueprint capture, not from your DB.Configuration
-------------

[](#configuration)

```
php artisan vendor:publish --tag=model-studio-config
```

KeyDefaultPurpose`enabled``null``null` → available everywhere **except production**. Override with `MODEL_STUDIO_ENABLED=true/false`.`path``model-studio`Route prefix.`middleware``['web']`Add `auth` etc. to protect the UI.`models_path``app_path('Models')`Where models are scanned and written.`models_namespace``App\Models`Namespace for scanned and generated models.`ignore_tables`framework tablesTables that should never get models (migrations, jobs, cache, spatie pivot tables, …).Guarantees
----------

[](#guarantees)

- **Existing models are never overwritten** — drift is reported, fixes are copy-paste snippets, and the write endpoint refuses tables that already have a model.
- **Your database is never queried** — the schema comes entirely from migration files.
- Generation is previewed in the UI before any file is written.

Known limits
------------

[](#known-limits)

- Relations are inferred from real foreign key constraints — implicit relationships without FK constraints aren't detected.
- `morphMany`/`morphedByMany` inverses can't be inferred reliably and are left to you.
- Drift checks cover `$fillable`, `$casts`, and relation methods — not accessors, scopes, or observers (those are yours).

License
-------

[](#license)

MIT

laravel-model-studio
====================

[](#laravel-model-studio)

###  Health Score

35

—

LowBetter than 77% of packages

Maintenance100

Actively maintained with recent releases

Popularity2

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity28

Early-stage or recently created project

 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

0d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/d7b7c2556272b7d41b2b756e7791f812c3a22b8ab34fa69d47ae1d8806b67cb6?d=identicon)[hussein4alaa](/maintainers/hussein4alaa)

---

Top Contributors

[![hussein4alaa](https://avatars.githubusercontent.com/u/13614747?v=4)](https://github.com/hussein4alaa "hussein4alaa (3 commits)")

---

Tags

laravelgeneratoreloquentmigrationsmodels

### Embed Badge

![Health badge](/badges/g4t-model-studio/health.svg)

```
[![Health](https://phpackages.com/badges/g4t-model-studio/health.svg)](https://phpackages.com/packages/g4t-model-studio)
```

###  Alternatives

[anourvalar/eloquent-serialize

Laravel Query Builder (Eloquent) serialization

11223.5M33](/packages/anourvalar-eloquent-serialize)[daavelar/revengedb

RevengeDb provides an artisan command to make a reverse engineer of the database, generating automatically the migrations for you

203.1k](/packages/daavelar-revengedb)

PHPackages © 2026

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