Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Laravel Laravel Package

reliese/laravel

Generate Laravel Eloquent models from your database schema. Reliese inspects tables, columns, and foreign keys to scaffold typed model properties and relationships via an Artisan command, helping speed up development (best used in local/dev environments).

View on GitHub
Deep Wiki
Context7

Getting Started

  1. Install as a dev dependency: composer require reliese/laravel --dev.
  2. Publish the config: php artisan vendor:publish --tag=reliese-models, then clear config cache (php artisan config:clear).
  3. Configure your database connection in .env (ensure it’s accessible to the app).
  4. Run php artisan code:models to generate models from your current DB.
  5. Start by scaffolding one table (--table=users) to verify output before full generation.

Implementation Patterns

  • DB-First Workflow: Use this package early in development to generate Eloquent models that reflect your schema—ideal for legacy databases or when schema-first design is mandated.
  • Incremental Refactoring: After schema changes (e.g., adding columns or FKs), re-run code:models to keep relationships and types in sync.
  • Base File Strategy: Enable base_files => true in config/models.php to preserve custom logic (e.g., custom accessors) in your generated models. Your custom model classes extend the base generated class and are never overwritten.
  • Selective Generation: Use flags like --connection, --schema, --table, or --only (whitelist) to scaffold only needed models—especially useful in multi-tenant or microservice setups.
  • Custom Naming: Leverage model_namespace, table_prefix, pluralize, or relation_name_strategy in config/models.php to align output with your project’s conventions (e.g., omitting pluralization for singular model names).

Gotchas and Tips

  • Base Files ≠ Merge: Base models are overwritten on each run. Never modify them—only add logic to the non-base subclass (which extends the base). Confusing this pattern leads to lost work.
  • FK & Index quirks: Models depend on DB integrity. Missing PKs or inconsistent FKs may cause generation failures (check changelog: v0.0.12 fixed PK handling). MySQL’s set type defaults to string casting—adjust if needed.
  • Cast Safety: In v1.2.0+, $dates is fully deprecated. Ensure your DB timestamps (created_at, updated_at) remain auto-cast; custom date columns should be explicitly cast as 'datetime'.
  • Soft Deletes: The deleted_at column is typed as string in docblocks—ensure you’re not relying on its automatic Carbon casting in relationships unless overridden.
  • Nullable Relationships: When foreign key columns allow NULL, relationships are auto-nullable (e.g., BelongsTo)—good for optional relations, but verify in tests if your schema evolves.
  • Laravel Version Gotchas: Postgres support improved in v0.0.15 and v1.3.4; Laravel 11 support was added in v1.3.2/v1.4.0—avoid older versions if using Laravel 11+.
  • Config Caching: Always run php artisan config:clear after editing config/models.php, especially in production-like environments where cached configs are common.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport