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.

Maintainers

Package info

github.com/hussein4alaa/laravel-model-studio

pkg:composer/g4t/model-studio

Transparency log

Statistics

Installs: 1

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

0.0.1 2026-07-27 10:53 UTC

This package is auto-updated.

Last update: 2026-07-27 10:54:24 UTC


README

g4t Model Studio — your migrations already know your models

Packagist Laravel 8 to 13 PHP ^8.0 MIT

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 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

composer require g4t/model-studio

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

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

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

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

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

php artisan vendor:publish --tag=model-studio-config
Key Default Purpose
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 tables Tables that should never get models (migrations, jobs, cache, spatie pivot tables, …).

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

  • 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

MIT

laravel-model-studio